@@ -268,8 +268,7 @@ pub struct CancelData {
268268/// thread::spawn(move || {
269269/// conn.execute("SOME EXPENSIVE QUERY", &[]).unwrap();
270270/// });
271- /// # let _ =
272- /// postgres::cancel_query(url, &SslMode::None, cancel_data);
271+ /// postgres::cancel_query(url, &SslMode::None, cancel_data).unwrap();
273272/// ```
274273pub fn cancel_query < T > ( params : T ,
275274 ssl : & SslMode ,
@@ -873,25 +872,24 @@ impl Connection {
873872 /// # Examples
874873 ///
875874 /// ```rust,no_run
876- /// # use postgres::{Connection, SslMode};
877- /// # fn f() -> Result<(), ::postgres::error::ConnectError> {
875+ /// use postgres::{Connection, SslMode};
876+ ///
878877 /// let url = "postgresql://postgres:hunter2@localhost:2994/foodb";
879- /// let conn = try!(Connection::connect(url, &SslMode::None));
880- /// # Ok(()) };
878+ /// let conn = Connection::connect(url, &SslMode::None).unwrap();
881879 /// ```
882880 ///
883881 /// ```rust,no_run
884- /// # use postgres::{Connection, SslMode};
885- /// # fn f() -> Result<(), ::postgres::error::ConnectError> {
882+ /// use postgres::{Connection, SslMode};
883+ ///
886884 /// let url = "postgresql://postgres@%2Frun%2Fpostgres";
887- /// let conn = try!(Connection::connect(url, &SslMode::None));
888- /// # Ok(()) };
885+ /// let conn = Connection::connect(url, &SslMode::None).unwrap();
889886 /// ```
890887 ///
891888 /// ```rust,no_run
892- /// # use postgres::{Connection, UserInfo, ConnectParams, SslMode, ConnectTarget};
889+ /// use postgres::{Connection, UserInfo, ConnectParams, SslMode, ConnectTarget};
890+ ///
893891 /// # #[cfg(feature = "unix_socket")]
894- /// # fn f() -> Result<(), ::postgres::error::ConnectError> {
892+ /// # fn f() {
895893 /// # let some_crazy_path = Path::new("");
896894 /// let params = ConnectParams {
897895 /// target: ConnectTarget::Unix(some_crazy_path),
@@ -903,8 +901,8 @@ impl Connection {
903901 /// database: None,
904902 /// options: vec![],
905903 /// };
906- /// let conn = try!( Connection::connect(params, &SslMode::None));
907- /// # Ok(()) };
904+ /// let conn = Connection::connect(params, &SslMode::None).unwrap( );
905+ /// # }
908906 /// ```
909907 pub fn connect < T > ( params : T , ssl : & SslMode ) -> result:: Result < Connection , ConnectError >
910908 where T : IntoConnectParams
@@ -937,12 +935,14 @@ impl Connection {
937935 ///
938936 /// ```rust,no_run
939937 /// # use postgres::{Connection, SslMode};
938+ /// # let x = 10i32;
940939 /// # let conn = Connection::connect("", &SslMode::None).unwrap();
941- /// let maybe_stmt = conn.prepare("SELECT foo FROM bar WHERE baz = $1");
942- /// let stmt = match maybe_stmt {
943- /// Ok(stmt) => stmt,
944- /// Err(err) => panic!("Error preparing statement: {:?}", err)
945- /// };
940+ /// let stmt = conn.prepare("SELECT foo FROM bar WHERE baz = $1").unwrap();
941+ /// for row in stmt.query(&[&x]).unwrap() {
942+ /// let foo: String = row.get(0);
943+ /// println!("foo: {}", foo);
944+ /// }
945+ /// ```
946946 pub fn prepare < ' a > ( & ' a self , query : & str ) -> Result < Statement < ' a > > {
947947 self . conn . borrow_mut ( ) . prepare ( query, self )
948948 }
@@ -958,14 +958,13 @@ impl Connection {
958958 ///
959959 /// ```rust,no_run
960960 /// # use postgres::{Connection, SslMode};
961- /// # fn f() -> postgres::Result<()> {
962961 /// # let x = 10i32;
963962 /// # let conn = Connection::connect("", &SslMode::None).unwrap();
964- /// let stmt = try!(conn.prepare_cached("SELECT foo FROM bar WHERE baz = $1"));
965- /// for row in try!(stmt.query(&[&x])) {
966- /// println!("foo: {}", row.get::<_, String>(0));
963+ /// let stmt = conn.prepare_cached("SELECT foo FROM bar WHERE baz = $1").unwrap();
964+ /// for row in stmt.query(&[&x]).unwrap() {
965+ /// let foo: String = row.get(0);
966+ /// println!("foo: {}", foo);
967967 /// }
968- /// # Ok(()) };
969968 /// ```
970969 pub fn prepare_cached < ' a > ( & ' a self , query : & str ) -> Result < Statement < ' a > > {
971970 self . conn . borrow_mut ( ) . prepare_cached ( query, self )
@@ -989,15 +988,12 @@ impl Connection {
989988 ///
990989 /// ```rust,no_run
991990 /// # use postgres::{Connection, SslMode};
992- /// # fn foo() -> Result<(), postgres::error::Error> {
993991 /// # let conn = Connection::connect("", &SslMode::None).unwrap();
994- /// let trans = try!( conn.transaction());
995- /// try!( trans.execute("UPDATE foo SET bar = 10", &[]));
992+ /// let trans = conn.transaction().unwrap( );
993+ /// trans.execute("UPDATE foo SET bar = 10", &[]).unwrap( );
996994 /// // ...
997995 ///
998- /// try!(trans.commit());
999- /// # Ok(())
1000- /// # }
996+ /// trans.commit().unwrap();
1001997 /// ```
1002998 pub fn transaction < ' a > ( & ' a self ) -> Result < Transaction < ' a > > {
1003999 let mut conn = self . conn . borrow_mut ( ) ;
@@ -1074,23 +1070,22 @@ impl Connection {
10741070 /// # Example
10751071 ///
10761072 /// ```rust,no_run
1077- /// # use postgres::{Connection, Result};
1078- /// fn init_db( conn: &Connection) -> Result<()> {
1079- /// conn.batch_execute("
1080- /// CREATE TABLE person (
1081- /// id SERIAL PRIMARY KEY,
1082- /// name NOT NULL
1083- /// );
1073+ /// # use postgres::{Connection, SslMode, Result};
1074+ /// # let conn = Connection::connect("", &SslMode::None).unwrap();
1075+ /// conn.batch_execute("
1076+ /// CREATE TABLE person (
1077+ /// id SERIAL PRIMARY KEY,
1078+ /// name NOT NULL
1079+ /// );
10841080 ///
1085- /// CREATE TABLE purchase (
1086- /// id SERIAL PRIMARY KEY,
1087- /// person INT NOT NULL REFERENCES person (id),
1088- /// time TIMESTAMPTZ NOT NULL,
1089- /// );
1081+ /// CREATE TABLE purchase (
1082+ /// id SERIAL PRIMARY KEY,
1083+ /// person INT NOT NULL REFERENCES person (id),
1084+ /// time TIMESTAMPTZ NOT NULL,
1085+ /// );
10901086 ///
1091- /// CREATE INDEX ON purchase (time);
1092- /// ")
1093- /// }
1087+ /// CREATE INDEX ON purchase (time);
1088+ /// ").unwrap();
10941089 /// ```
10951090 pub fn batch_execute ( & self , query : & str ) -> Result < ( ) > {
10961091 self . conn . borrow_mut ( ) . quick_query ( query) . map ( |_| ( ) )
0 commit comments