Skip to content

Commit 3cf70fa

Browse files
committed
Use no_run for doc tests
1 parent 8034413 commit 3cf70fa

3 files changed

Lines changed: 9 additions & 35 deletions

File tree

src/lib.rs

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Rust-Postgres is a pure-Rust frontend for the popular PostgreSQL database. It
33
exposes a high level interface in the vein of JDBC or Go's `database/sql`
44
package.
55
6-
```rust
6+
```rust,no_run
77
extern crate postgres;
88
extern crate time;
99
@@ -19,7 +19,6 @@ struct Person {
1919
data: Option<~[u8]>
2020
}
2121
22-
# fn main() {
2322
fn main() {
2423
let conn = PostgresConnection::connect("postgres://postgres@localhost",
2524
&NoSsl);
@@ -52,7 +51,6 @@ fn main() {
5251
println!("Found person {}", person.name);
5352
}
5453
}
55-
# }
5654
```
5755
*/
5856

@@ -270,10 +268,7 @@ pub struct PostgresCancelData {
270268
///
271269
/// # Example
272270
///
273-
/// ```rust
274-
/// # extern crate postgres;
275-
/// # fn main() {}
276-
/// # fn foo() {
271+
/// ```rust,no_run
277272
/// # use postgres::{PostgresConnection, NoSsl};
278273
/// # let url = "";
279274
/// let conn = PostgresConnection::connect(url, &NoSsl);
@@ -283,7 +278,6 @@ pub struct PostgresCancelData {
283278
/// });
284279
/// # let _ =
285280
/// postgres::cancel_query(url, &NoSsl, cancel_data);
286-
/// # }
287281
/// ```
288282
pub fn cancel_query(url: &str, ssl: &SslMode, data: PostgresCancelData)
289283
-> Result<(), PostgresConnectError> {
@@ -712,17 +706,14 @@ impl PostgresConnection {
712706
///
713707
/// # Example
714708
///
715-
/// ```rust
716-
/// # fn main() {}
717-
/// # fn foo() {
709+
/// ```rust,no_run
718710
/// # use postgres::{PostgresConnection, NoSsl};
719711
/// let url = "postgres://postgres:hunter2@localhost:2994/foodb";
720712
/// let maybe_conn = PostgresConnection::try_connect(url, &NoSsl);
721713
/// let conn = match maybe_conn {
722714
/// Ok(conn) => conn,
723715
/// Err(err) => fail!("Error connecting: {}", err)
724716
/// };
725-
/// # }
726717
/// ```
727718
pub fn try_connect(url: &str, ssl: &SslMode)
728719
-> Result<PostgresConnection, PostgresConnectError> {
@@ -772,17 +763,14 @@ impl PostgresConnection {
772763
///
773764
/// # Example
774765
///
775-
/// ```rust
766+
/// ```rust,no_run
776767
/// # use postgres::{PostgresConnection, NoSsl};
777-
/// # fn main() {}
778-
/// # fn foo() {
779768
/// # let conn = PostgresConnection::connect("", &NoSsl);
780769
/// let maybe_stmt = conn.try_prepare("SELECT foo FROM bar WHERE baz = $1");
781770
/// let stmt = match maybe_stmt {
782771
/// Ok(stmt) => stmt,
783772
/// Err(err) => fail!("Error preparing statement: {}", err)
784773
/// };
785-
/// # }
786774
pub fn try_prepare<'a>(&'a self, query: &str)
787775
-> Result<NormalPostgresStatement<'a>, PostgresError> {
788776
self.conn.with_mut(|conn| conn.try_prepare(query, self))
@@ -811,9 +799,8 @@ impl PostgresConnection {
811799
///
812800
/// # Example
813801
///
814-
/// ```rust
802+
/// ```rust,no_run
815803
/// # use postgres::{PostgresConnection, NoSsl};
816-
/// # fn main() {}
817804
/// # fn foo() -> Result<(), postgres::error::PostgresError> {
818805
/// # let conn = PostgresConnection::connect("", &NoSsl);
819806
/// let trans = try!(conn.try_transaction());

src/pool.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,9 @@ impl InnerConnectionPool {
3636
///
3737
/// # Example
3838
///
39-
/// ```rust
39+
/// ```rust,no_run
4040
/// # use postgres::NoSsl;
4141
/// # use postgres::pool::PostgresConnectionPool;
42-
/// # fn main() {}
43-
/// # fn foo() {
4442
/// let pool = PostgresConnectionPool::new("postgres://postgres@localhost",
4543
/// NoSsl, 5);
4644
/// for _ in range(0, 10) {
@@ -50,7 +48,6 @@ impl InnerConnectionPool {
5048
/// conn.execute("UPDATE foo SET bar = 1", []);
5149
/// });
5250
/// }
53-
/// # }
5451
/// ```
5552
#[deriving(Clone)]
5653
pub struct PostgresConnectionPool {

src/stmt.rs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,9 @@ pub trait PostgresStatement {
4040
///
4141
/// # Example
4242
///
43-
/// ```rust
43+
/// ```rust,no_run
4444
/// # use postgres::{PostgresConnection, NoSsl, PostgresStatement};
4545
/// # use postgres::types::ToSql;
46-
/// # fn main() {}
47-
/// # fn foo() {
4846
/// # let conn = PostgresConnection::connect("", &NoSsl);
4947
/// # let bar = 1i32;
5048
/// # let baz = true;
@@ -53,7 +51,6 @@ pub trait PostgresStatement {
5351
/// Ok(count) => println!("{} row(s) updated", count),
5452
/// Err(err) => println!("Error executing query: {}", err)
5553
/// }
56-
/// # }
5754
fn try_execute(&self, params: &[&ToSql]) -> Result<uint, PostgresError>;
5855

5956
/// A convenience function wrapping `try_execute`.
@@ -78,11 +75,9 @@ pub trait PostgresStatement {
7875
///
7976
/// # Example
8077
///
81-
/// ```rust
78+
/// ```rust,no_run
8279
/// # use postgres::{PostgresConnection, NoSsl, PostgresStatement};
8380
/// # use postgres::types::ToSql;
84-
/// # fn main() {}
85-
/// # fn foo() {
8681
/// # let conn = PostgresConnection::connect("", &NoSsl);
8782
/// let stmt = conn.prepare("SELECT foo FROM bar WHERE baz = $1");
8883
/// # let baz = true;
@@ -94,7 +89,6 @@ pub trait PostgresStatement {
9489
/// let foo: i32 = row["foo"];
9590
/// println!("foo: {}", foo);
9691
/// }
97-
/// # }
9892
/// ```
9993
fn try_query<'a>(&'a self, params: &[&ToSql])
10094
-> Result<PostgresResult<'a>, PostgresError>;
@@ -509,18 +503,14 @@ impl<'stmt> Iterator<PostgresRow<'stmt>> for PostgresResult<'stmt> {
509503
/// A value can be accessed by the name or index of its column, though access
510504
/// by index is more efficient. Rows are 1-indexed.
511505
///
512-
/// ```rust
513-
/// # extern crate postgres;
506+
/// ```rust,no_run
514507
/// # use postgres::{PostgresConnection, PostgresStatement, NoSsl};
515-
/// # fn main() {}
516-
/// # fn foo() {
517508
/// # let conn = PostgresConnection::connect("", &NoSsl);
518509
/// # let stmt = conn.prepare("");
519510
/// # let mut result = stmt.query([]);
520511
/// # let row = result.next().unwrap();
521512
/// let foo: i32 = row[1];
522513
/// let bar: ~str = row["bar"];
523-
/// # }
524514
/// ```
525515
pub struct PostgresRow<'stmt> {
526516
priv stmt: &'stmt NormalPostgresStatement<'stmt>,

0 commit comments

Comments
 (0)