Skip to content

Commit fa34efb

Browse files
committed
Change docs to work around coercion issue
1 parent 7a84a16 commit fa34efb

2 files changed

Lines changed: 6 additions & 23 deletions

File tree

README.md

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fn main() {
4343
};
4444
conn.execute("INSERT INTO person (name, time_created, data)
4545
VALUES ($1, $2, $3)",
46-
[&me.name, &me.time_created, &me.data]).unwrap();
46+
&[&me.name, &me.time_created, &me.data]).unwrap();
4747

4848
let stmt = conn.prepare("SELECT id, name, time_created, data FROM person")
4949
.unwrap();
@@ -103,7 +103,7 @@ Both methods take an array of parameters to bind to the query represented as
103103
query (or 0 if not applicable):
104104
```rust
105105
let stmt = try!(conn.prepare("UPDATE foo SET bar = $1 WHERE baz = $2"));
106-
let updates = try!(stmt.execute([&1i32, &"biz"]));
106+
let updates = try!(stmt.execute(&[&1i32, &"biz"]));
107107
println!("{} rows were updated", updates);
108108
```
109109
`query` returns an iterator over the rows returned from the database. The
@@ -122,7 +122,7 @@ In addition, `PostgresConnection` has a utility `execute` method which is useful
122122
if a statement is only going to be executed once:
123123
```rust
124124
let updates = try!(conn.execute("UPDATE foo SET bar = $1 WHERE baz = $2",
125-
[&1i32, &"biz"]));
125+
&[&1i32, &"biz"]));
126126
println!("{} rows were updated", updates);
127127
```
128128

@@ -146,23 +146,6 @@ The transaction will be active until the `PostgresTransaction` object falls out
146146
of scope. A transaction will roll back by default. Nested transactions are
147147
supported via savepoints.
148148

149-
### Connection Pooling
150-
A very basic fixed-size connection pool is provided in the `pool` module. A
151-
single pool can be shared across tasks and `get_connection` will block until a
152-
connection is available.
153-
```rust
154-
let pool = try!(PostgresConnectionPool::new("postgres://postgres@localhost",
155-
NoSsl, 5));
156-
157-
for _ in range(0, 10) {
158-
let pool = pool.clone();
159-
spawn(proc() {
160-
let conn = pool.get_connection();
161-
conn.query(...).unwrap();
162-
})
163-
}
164-
```
165-
166149
### Type Correspondence
167150
Rust-Postgres enforces a strict correspondence between Rust types and Postgres
168151
types. The driver currently supports the following conversions:

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
//! };
3636
//! conn.execute("INSERT INTO person (name, time_created, data)
3737
//! VALUES ($1, $2, $3)",
38-
//! [&me.name, &me.time_created, &me.data]).unwrap();
38+
//! &[&me.name, &me.time_created, &me.data]).unwrap();
3939
//!
4040
//! let stmt = conn.prepare("SELECT id, name, time_created, data FROM person")
4141
//! .unwrap();
@@ -1172,7 +1172,7 @@ impl<'conn> PostgresStatement<'conn> {
11721172
/// # let bar = 1i32;
11731173
/// # let baz = true;
11741174
/// let stmt = conn.prepare("UPDATE foo SET bar = $1 WHERE baz = $2").unwrap();
1175-
/// match stmt.execute([&bar, &baz]) {
1175+
/// match stmt.execute(&[&bar, &baz]) {
11761176
/// Ok(count) => println!("{} row(s) updated", count),
11771177
/// Err(err) => println!("Error executing query: {}", err)
11781178
/// }
@@ -1218,7 +1218,7 @@ impl<'conn> PostgresStatement<'conn> {
12181218
/// # let conn = PostgresConnection::connect("", &NoSsl).unwrap();
12191219
/// let stmt = conn.prepare("SELECT foo FROM bar WHERE baz = $1").unwrap();
12201220
/// # let baz = true;
1221-
/// let mut rows = match stmt.query([&baz]) {
1221+
/// let mut rows = match stmt.query(&[&baz]) {
12221222
/// Ok(rows) => rows,
12231223
/// Err(err) => fail!("Error running query: {}", err)
12241224
/// };

0 commit comments

Comments
 (0)