Improve examples a bit

This commit is contained in:
Steven Fackler 2014-08-19 21:49:27 -07:00
parent 699a3f1acc
commit b8539003c3

View File

@ -438,8 +438,7 @@ impl InnerPostgresConnection {
Ok(conn) Ok(conn)
} }
fn write_messages(&mut self, messages: &[FrontendMessage]) fn write_messages(&mut self, messages: &[FrontendMessage]) -> IoResult<()> {
-> IoResult<()> {
debug_assert!(!self.desynchronized); debug_assert!(!self.desynchronized);
for message in messages.iter() { for message in messages.iter() {
try_desync!(self, self.stream.write_message(message)); try_desync!(self, self.stream.write_message(message));
@ -627,8 +626,7 @@ impl InnerPostgresConnection {
} }
} }
fn quick_query(&mut self, query: &str) fn quick_query(&mut self, query: &str) -> PostgresResult<Vec<Vec<Option<String>>>> {
-> PostgresResult<Vec<Vec<Option<String>>>> {
check_desync!(self); check_desync!(self);
try_pg!(self.write_messages([Query { query: query }])); try_pg!(self.write_messages([Query { query: query }]));
@ -688,22 +686,23 @@ impl PostgresConnection {
/// ///
/// ```rust,no_run /// ```rust,no_run
/// # use postgres::{PostgresConnection, NoSsl}; /// # use postgres::{PostgresConnection, NoSsl};
/// # let _ = || {
/// let url = "postgresql://postgres:hunter2@localhost:2994/foodb"; /// let url = "postgresql://postgres:hunter2@localhost:2994/foodb";
/// let maybe_conn = PostgresConnection::connect(url, &NoSsl); /// let conn = try!(PostgresConnection::connect(url, &NoSsl));
/// let conn = match maybe_conn { /// # Ok(()) };
/// Ok(conn) => conn,
/// Err(err) => fail!("Error connecting: {}", err)
/// };
/// ``` /// ```
/// ///
/// ```rust,no_run /// ```rust,no_run
/// # use postgres::{PostgresConnection, NoSsl}; /// # use postgres::{PostgresConnection, NoSsl};
/// # let _ = || {
/// let url = "postgresql://postgres@%2Frun%2Fpostgres"; /// let url = "postgresql://postgres@%2Frun%2Fpostgres";
/// let maybe_conn = PostgresConnection::connect(url, &NoSsl); /// let conn = try!(PostgresConnection::connect(url, &NoSsl));
/// # Ok(()) };
/// ``` /// ```
/// ///
/// ```rust,no_run /// ```rust,no_run
/// # use postgres::{PostgresConnection, PostgresUserInfo, PostgresConnectParams, NoSsl, TargetUnix}; /// # use postgres::{PostgresConnection, PostgresUserInfo, PostgresConnectParams, NoSsl, TargetUnix};
/// # let _ = || {
/// # let some_crazy_path = Path::new(""); /// # let some_crazy_path = Path::new("");
/// let params = PostgresConnectParams { /// let params = PostgresConnectParams {
/// target: TargetUnix(some_crazy_path), /// target: TargetUnix(some_crazy_path),
@ -715,7 +714,8 @@ impl PostgresConnection {
/// database: None, /// database: None,
/// options: vec![], /// options: vec![],
/// }; /// };
/// let maybe_conn = PostgresConnection::connect(params, &NoSsl); /// let conn = try!(PostgresConnection::connect(params, &NoSsl));
/// # Ok(()) };
/// ``` /// ```
pub fn connect<T>(params: T, ssl: &SslMode) -> Result<PostgresConnection, PostgresConnectError> pub fn connect<T>(params: T, ssl: &SslMode) -> Result<PostgresConnection, PostgresConnectError>
where T: IntoConnectParams { where T: IntoConnectParams {