"serve" => { let sdb = Arc::new(Mutex::new(db)); let mut router = router::Router::new(); { let sdb_ = sdb.clone(); router.get("/api/v1/records", move |req: &mut Request| handlers::get_records(sdb_.clone(), req)); } { let sdb_ = sdb.clone(); router.get("/api/v1/records/:id", move |req: &mut Request| handlers::get_record(sdb_.clone(), req)); } { let sdb_ = sdb.clone(); router.post("/api/v1/records", move |req: &mut Request| handlers::add_record(sdb_.clone(), req)); } { let sdb_ = sdb.clone(); router.put("/api/v1/records/:id", move |req: &mut Request| handlers::update_record(sdb_.clone(), req)); } { let sdb_ = sdb.clone(); router.delete("/api/v1/records/:id", move |req: &mut Request| handlers::delete_record(sdb_.clone(), req)); } Iron::new(router).http("localhost:3000").unwrap(); }
let sdb = Arc::new(Mutex::new(db));
let mut router = router::Router::new(); { let sdb_ = sdb.clone(); router.get("/api/v1/records", move |req: &mut Request| handlers::get_records(sdb_.clone(), req)); }
pub trait Handler: Send + Sync + Any { fn handle(&self, &mut Request) -> IronResult<Response>; }
type IronResult<T> = Result<T, IronError>; pub struct IronError { ... }
pub trait Handler: Send + Sync + Any {
impl<T> !Send for *const T
impl<T> Send for AtomicPtr<T>
impl<T: Send> Send for Sender<T>
impl<T> Send for Arc<T> where T: Send + Sync + ?Sized impl<T> Sync for Arc<T> where T: Send + Sync + ?Sized impl<T: ?Sized + Send> Send for Mutex<T> impl<T: ?Sized + Send> Sync for Mutex<T>
let sdb = Arc::new(Mutex::new(db)); let mut router = router::Router::new(); { let sdb_ = sdb.clone(); router.get("/api/v1/records", move |req: &mut Request| handlers::get_records(sdb_.clone(), req)); }
move |req: &mut Request| handlers::get_records(sdb_.clone(), req));
fn handle(&self, &mut Request) -> IronResult<Response>;
{ let sdb_ = sdb.clone(); router.get("/api/v1/records", move |req: &mut Request| handlers::get_records(sdb_, req)); }
main.rs:120:32: 122: 69 error: the trait `for <'r,' r, 'r> core :: ops :: Fn <(&' r mut iron :: request :: Request <'r , 'r>,)> `not for the type of [closure@main.rs: 121: 36: 122: 68 sdb_: alloc :: arc :: Arc <std :: sync :: mutex :: Mutex < postgres :: Connection >>] `[E0277] main.rs:120 router.get ("/ api / v1 / records", main.rs:121 move | req: & mut Request | main.rs:122 handlers :: get_records (sdb_, req)); main.rs:120:32: 122: 69 help: run `rustc --explain E0277` to see a detailed explanation
Arc<Mutex> . , .
, ? Rust |x| x + 1 - . - , . .
Fn? , Handler Iron' Fn:
impl<F> Handler for F where F: Send + Sync + Any + Fn(&mut Request) -> IronResult<Response> { fn handle(&self, req: &mut Request) -> IronResult<Response> { (*self)(req) } }
where - . , F, Send + Sync + Any + Fn(&mut Request) -> IronResult.
, Handler Fn. Iron, , : - , .
Rust! .
- move . move , , . move :
main.rs:121:36: 122:76 error: closure may outlive the current function, but it borrows `sdb_`, which is owned by the current function [E0373] main.rs:121 |req: &mut Request| main.rs:122 handlers::get_records(sdb_.clone(), req)); main.rs:121:36: 122:76 help: run `rustc --explain E0373` to see a detailed explanation main.rs:122:58: 122:62 note: `sdb_` is borrowed here main.rs:122 handlers::get_records(sdb_.clone(), req)); ^~~~ main.rs:121:36: 122:76 help: to force the closure to take ownership of `sdb_` (and any other referenced variables), use the `move` keyword, as shown: main.rs: move |req: &mut Request| main.rs: handlers::get_records(sdb_.clone(), req)); error: aborting due to previous error
sdb_, main - Iron . , , , - main, .
Rust . .
: sdb ?
let sdb_ = sdb.clone();
:
main.rs:125:36: 125:39 error: use of moved value: `sdb` [E0382] main.rs:125 let sdb_ = sdb.clone(); ^~~ main.rs:125:36: 125:39 help: run `rustc --explain E0382` to see a detailed explanation main.rs:119:29: 119:33 note: `sdb` moved here because it has type `alloc::arc::Arc<std::sync::mutex::Mutex<postgres::Connection>>`, which is moved by default main.rs:119 let sdb_ = sdb; ^~~~
. , , GET/id:
{ let sdb_ = sdb.clone(); router.get("/api/v1/records/:id", move |req: &mut Request| handlers::get_record(sdb_.clone(), req)); }
:id, Router', URL , .
HTTP- Router' :
Iron::new(router).http("localhost:3000").unwrap();
? ! , Rust. , - Mutex Arc.
- .
Arc<Mutex> . , .
, ? Rust |x| x + 1 - . - , . .
Fn? , Handler Iron' Fn:
impl<F> Handler for F where F: Send + Sync + Any + Fn(&mut Request) -> IronResult<Response> { fn handle(&self, req: &mut Request) -> IronResult<Response> { (*self)(req) } }
where - . , F, Send + Sync + Any + Fn(&mut Request) -> IronResult.
, Handler Fn. Iron, , : - , .
Rust! .
- move . move , , . move :
main.rs:121:36: 122:76 error: closure may outlive the current function, but it borrows `sdb_`, which is owned by the current function [E0373] main.rs:121 |req: &mut Request| main.rs:122 handlers::get_records(sdb_.clone(), req)); main.rs:121:36: 122:76 help: run `rustc --explain E0373` to see a detailed explanation main.rs:122:58: 122:62 note: `sdb_` is borrowed here main.rs:122 handlers::get_records(sdb_.clone(), req)); ^~~~ main.rs:121:36: 122:76 help: to force the closure to take ownership of `sdb_` (and any other referenced variables), use the `move` keyword, as shown: main.rs: move |req: &mut Request| main.rs: handlers::get_records(sdb_.clone(), req)); error: aborting due to previous error
sdb_, main - Iron . , , , - main, .
Rust . .
: sdb ?
let sdb_ = sdb.clone();
:
main.rs:125:36: 125:39 error: use of moved value: `sdb` [E0382] main.rs:125 let sdb_ = sdb.clone(); ^~~ main.rs:125:36: 125:39 help: run `rustc --explain E0382` to see a detailed explanation main.rs:119:29: 119:33 note: `sdb` moved here because it has type `alloc::arc::Arc<std::sync::mutex::Mutex<postgres::Connection>>`, which is moved by default main.rs:119 let sdb_ = sdb; ^~~~
. , , GET/id:
{ let sdb_ = sdb.clone(); router.get("/api/v1/records/:id", move |req: &mut Request| handlers::get_record(sdb_.clone(), req)); }
:id, Router', URL , .
HTTP- Router' :
Iron::new(router).http("localhost:3000").unwrap();
? ! , Rust. , - Mutex Arc.
- .
Arc<Mutex> . , .
, ? Rust |x| x + 1 - . - , . .
Fn? , Handler Iron' Fn:
impl<F> Handler for F where F: Send + Sync + Any + Fn(&mut Request) -> IronResult<Response> { fn handle(&self, req: &mut Request) -> IronResult<Response> { (*self)(req) } }
where - . , F, Send + Sync + Any + Fn(&mut Request) -> IronResult.
, Handler Fn. Iron, , : - , .
Rust! .
- move . move , , . move :
main.rs:121:36: 122:76 error: closure may outlive the current function, but it borrows `sdb_`, which is owned by the current function [E0373] main.rs:121 |req: &mut Request| main.rs:122 handlers::get_records(sdb_.clone(), req)); main.rs:121:36: 122:76 help: run `rustc --explain E0373` to see a detailed explanation main.rs:122:58: 122:62 note: `sdb_` is borrowed here main.rs:122 handlers::get_records(sdb_.clone(), req)); ^~~~ main.rs:121:36: 122:76 help: to force the closure to take ownership of `sdb_` (and any other referenced variables), use the `move` keyword, as shown: main.rs: move |req: &mut Request| main.rs: handlers::get_records(sdb_.clone(), req)); error: aborting due to previous error
sdb_, main - Iron . , , , - main, .
Rust . .
: sdb ?
let sdb_ = sdb.clone();
:
main.rs:125:36: 125:39 error: use of moved value: `sdb` [E0382] main.rs:125 let sdb_ = sdb.clone(); ^~~ main.rs:125:36: 125:39 help: run `rustc --explain E0382` to see a detailed explanation main.rs:119:29: 119:33 note: `sdb` moved here because it has type `alloc::arc::Arc<std::sync::mutex::Mutex<postgres::Connection>>`, which is moved by default main.rs:119 let sdb_ = sdb; ^~~~
. , , GET/id:
{ let sdb_ = sdb.clone(); router.get("/api/v1/records/:id", move |req: &mut Request| handlers::get_record(sdb_.clone(), req)); }
:id, Router', URL , .
HTTP- Router' :
Iron::new(router).http("localhost:3000").unwrap();
? ! , Rust. , - Mutex Arc.
- .
Arc<Mutex> . , .
, ? Rust |x| x + 1 - . - , . .
Fn? , Handler Iron' Fn:
impl<F> Handler for F where F: Send + Sync + Any + Fn(&mut Request) -> IronResult<Response> { fn handle(&self, req: &mut Request) -> IronResult<Response> { (*self)(req) } }
where - . , F, Send + Sync + Any + Fn(&mut Request) -> IronResult.
, Handler Fn. Iron, , : - , .
Rust! .
- move . move , , . move :
main.rs:121:36: 122:76 error: closure may outlive the current function, but it borrows `sdb_`, which is owned by the current function [E0373] main.rs:121 |req: &mut Request| main.rs:122 handlers::get_records(sdb_.clone(), req)); main.rs:121:36: 122:76 help: run `rustc --explain E0373` to see a detailed explanation main.rs:122:58: 122:62 note: `sdb_` is borrowed here main.rs:122 handlers::get_records(sdb_.clone(), req)); ^~~~ main.rs:121:36: 122:76 help: to force the closure to take ownership of `sdb_` (and any other referenced variables), use the `move` keyword, as shown: main.rs: move |req: &mut Request| main.rs: handlers::get_records(sdb_.clone(), req)); error: aborting due to previous error
sdb_, main - Iron . , , , - main, .
Rust . .
: sdb ?
let sdb_ = sdb.clone();
:
main.rs:125:36: 125:39 error: use of moved value: `sdb` [E0382] main.rs:125 let sdb_ = sdb.clone(); ^~~ main.rs:125:36: 125:39 help: run `rustc --explain E0382` to see a detailed explanation main.rs:119:29: 119:33 note: `sdb` moved here because it has type `alloc::arc::Arc<std::sync::mutex::Mutex<postgres::Connection>>`, which is moved by default main.rs:119 let sdb_ = sdb; ^~~~
. , , GET/id:
{ let sdb_ = sdb.clone(); router.get("/api/v1/records/:id", move |req: &mut Request| handlers::get_record(sdb_.clone(), req)); }
:id, Router', URL , .
HTTP- Router' :
Iron::new(router).http("localhost:3000").unwrap();
? ! , Rust. , - Mutex Arc.
- .
Arc<Mutex> . , .
, ? Rust |x| x + 1 - . - , . .
Fn? , Handler Iron' Fn:
impl<F> Handler for F where F: Send + Sync + Any + Fn(&mut Request) -> IronResult<Response> { fn handle(&self, req: &mut Request) -> IronResult<Response> { (*self)(req) } }
where - . , F, Send + Sync + Any + Fn(&mut Request) -> IronResult.
, Handler Fn. Iron, , : - , .
Rust! .
- move . move , , . move :
main.rs:121:36: 122:76 error: closure may outlive the current function, but it borrows `sdb_`, which is owned by the current function [E0373] main.rs:121 |req: &mut Request| main.rs:122 handlers::get_records(sdb_.clone(), req)); main.rs:121:36: 122:76 help: run `rustc --explain E0373` to see a detailed explanation main.rs:122:58: 122:62 note: `sdb_` is borrowed here main.rs:122 handlers::get_records(sdb_.clone(), req)); ^~~~ main.rs:121:36: 122:76 help: to force the closure to take ownership of `sdb_` (and any other referenced variables), use the `move` keyword, as shown: main.rs: move |req: &mut Request| main.rs: handlers::get_records(sdb_.clone(), req)); error: aborting due to previous error
sdb_, main - Iron . , , , - main, .
Rust . .
: sdb ?
let sdb_ = sdb.clone();
:
main.rs:125:36: 125:39 error: use of moved value: `sdb` [E0382] main.rs:125 let sdb_ = sdb.clone(); ^~~ main.rs:125:36: 125:39 help: run `rustc --explain E0382` to see a detailed explanation main.rs:119:29: 119:33 note: `sdb` moved here because it has type `alloc::arc::Arc<std::sync::mutex::Mutex<postgres::Connection>>`, which is moved by default main.rs:119 let sdb_ = sdb; ^~~~
. , , GET/id:
{ let sdb_ = sdb.clone(); router.get("/api/v1/records/:id", move |req: &mut Request| handlers::get_record(sdb_.clone(), req)); }
:id, Router', URL , .
HTTP- Router' :
Iron::new(router).http("localhost:3000").unwrap();
? ! , Rust. , - Mutex Arc.
- .
Arc<Mutex> . , .
, ? Rust |x| x + 1 - . - , . .
Fn? , Handler Iron' Fn:
impl<F> Handler for F where F: Send + Sync + Any + Fn(&mut Request) -> IronResult<Response> { fn handle(&self, req: &mut Request) -> IronResult<Response> { (*self)(req) } }
where - . , F, Send + Sync + Any + Fn(&mut Request) -> IronResult.
, Handler Fn. Iron, , : - , .
Rust! .
- move . move , , . move :
main.rs:121:36: 122:76 error: closure may outlive the current function, but it borrows `sdb_`, which is owned by the current function [E0373] main.rs:121 |req: &mut Request| main.rs:122 handlers::get_records(sdb_.clone(), req)); main.rs:121:36: 122:76 help: run `rustc --explain E0373` to see a detailed explanation main.rs:122:58: 122:62 note: `sdb_` is borrowed here main.rs:122 handlers::get_records(sdb_.clone(), req)); ^~~~ main.rs:121:36: 122:76 help: to force the closure to take ownership of `sdb_` (and any other referenced variables), use the `move` keyword, as shown: main.rs: move |req: &mut Request| main.rs: handlers::get_records(sdb_.clone(), req)); error: aborting due to previous error
sdb_, main - Iron . , , , - main, .
Rust . .
: sdb ?
let sdb_ = sdb.clone();
:
main.rs:125:36: 125:39 error: use of moved value: `sdb` [E0382] main.rs:125 let sdb_ = sdb.clone(); ^~~ main.rs:125:36: 125:39 help: run `rustc --explain E0382` to see a detailed explanation main.rs:119:29: 119:33 note: `sdb` moved here because it has type `alloc::arc::Arc<std::sync::mutex::Mutex<postgres::Connection>>`, which is moved by default main.rs:119 let sdb_ = sdb; ^~~~
. , , GET/id:
{ let sdb_ = sdb.clone(); router.get("/api/v1/records/:id", move |req: &mut Request| handlers::get_record(sdb_.clone(), req)); }
:id, Router', URL , .
HTTP- Router' :
Iron::new(router).http("localhost:3000").unwrap();
? ! , Rust. , - Mutex Arc.
- .
Arc<Mutex> . , .
, ? Rust |x| x + 1 - . - , . .
Fn? , Handler Iron' Fn:
impl<F> Handler for F where F: Send + Sync + Any + Fn(&mut Request) -> IronResult<Response> { fn handle(&self, req: &mut Request) -> IronResult<Response> { (*self)(req) } }
where - . , F, Send + Sync + Any + Fn(&mut Request) -> IronResult.
, Handler Fn. Iron, , : - , .
Rust! .
- move . move , , . move :
main.rs:121:36: 122:76 error: closure may outlive the current function, but it borrows `sdb_`, which is owned by the current function [E0373] main.rs:121 |req: &mut Request| main.rs:122 handlers::get_records(sdb_.clone(), req)); main.rs:121:36: 122:76 help: run `rustc --explain E0373` to see a detailed explanation main.rs:122:58: 122:62 note: `sdb_` is borrowed here main.rs:122 handlers::get_records(sdb_.clone(), req)); ^~~~ main.rs:121:36: 122:76 help: to force the closure to take ownership of `sdb_` (and any other referenced variables), use the `move` keyword, as shown: main.rs: move |req: &mut Request| main.rs: handlers::get_records(sdb_.clone(), req)); error: aborting due to previous error
sdb_, main - Iron . , , , - main, .
Rust . .
: sdb ?
let sdb_ = sdb.clone();
:
main.rs:125:36: 125:39 error: use of moved value: `sdb` [E0382] main.rs:125 let sdb_ = sdb.clone(); ^~~ main.rs:125:36: 125:39 help: run `rustc --explain E0382` to see a detailed explanation main.rs:119:29: 119:33 note: `sdb` moved here because it has type `alloc::arc::Arc<std::sync::mutex::Mutex<postgres::Connection>>`, which is moved by default main.rs:119 let sdb_ = sdb; ^~~~
. , , GET/id:
{ let sdb_ = sdb.clone(); router.get("/api/v1/records/:id", move |req: &mut Request| handlers::get_record(sdb_.clone(), req)); }
:id, Router', URL , .
HTTP- Router' :
Iron::new(router).http("localhost:3000").unwrap();
? ! , Rust. , - Mutex Arc.
- .
Arc<Mutex> . , .
, ? Rust |x| x + 1 - . - , . .
Fn? , Handler Iron' Fn:
impl<F> Handler for F where F: Send + Sync + Any + Fn(&mut Request) -> IronResult<Response> { fn handle(&self, req: &mut Request) -> IronResult<Response> { (*self)(req) } }
where - . , F, Send + Sync + Any + Fn(&mut Request) -> IronResult.
, Handler Fn. Iron, , : - , .
Rust! .
- move . move , , . move :
main.rs:121:36: 122:76 error: closure may outlive the current function, but it borrows `sdb_`, which is owned by the current function [E0373] main.rs:121 |req: &mut Request| main.rs:122 handlers::get_records(sdb_.clone(), req)); main.rs:121:36: 122:76 help: run `rustc --explain E0373` to see a detailed explanation main.rs:122:58: 122:62 note: `sdb_` is borrowed here main.rs:122 handlers::get_records(sdb_.clone(), req)); ^~~~ main.rs:121:36: 122:76 help: to force the closure to take ownership of `sdb_` (and any other referenced variables), use the `move` keyword, as shown: main.rs: move |req: &mut Request| main.rs: handlers::get_records(sdb_.clone(), req)); error: aborting due to previous error
sdb_, main - Iron . , , , - main, .
Rust . .
: sdb ?
let sdb_ = sdb.clone();
:
main.rs:125:36: 125:39 error: use of moved value: `sdb` [E0382] main.rs:125 let sdb_ = sdb.clone(); ^~~ main.rs:125:36: 125:39 help: run `rustc --explain E0382` to see a detailed explanation main.rs:119:29: 119:33 note: `sdb` moved here because it has type `alloc::arc::Arc<std::sync::mutex::Mutex<postgres::Connection>>`, which is moved by default main.rs:119 let sdb_ = sdb; ^~~~
. , , GET/id:
{ let sdb_ = sdb.clone(); router.get("/api/v1/records/:id", move |req: &mut Request| handlers::get_record(sdb_.clone(), req)); }
:id, Router', URL , .
HTTP- Router' :
Iron::new(router).http("localhost:3000").unwrap();
? ! , Rust. , - Mutex Arc.
- .
Arc<Mutex> . , .
, ? Rust |x| x + 1 - . - , . .
Fn? , Handler Iron' Fn:
impl<F> Handler for F where F: Send + Sync + Any + Fn(&mut Request) -> IronResult<Response> { fn handle(&self, req: &mut Request) -> IronResult<Response> { (*self)(req) } }
where - . , F, Send + Sync + Any + Fn(&mut Request) -> IronResult.
, Handler Fn. Iron, , : - , .
Rust! .
- move . move , , . move :
main.rs:121:36: 122:76 error: closure may outlive the current function, but it borrows `sdb_`, which is owned by the current function [E0373] main.rs:121 |req: &mut Request| main.rs:122 handlers::get_records(sdb_.clone(), req)); main.rs:121:36: 122:76 help: run `rustc --explain E0373` to see a detailed explanation main.rs:122:58: 122:62 note: `sdb_` is borrowed here main.rs:122 handlers::get_records(sdb_.clone(), req)); ^~~~ main.rs:121:36: 122:76 help: to force the closure to take ownership of `sdb_` (and any other referenced variables), use the `move` keyword, as shown: main.rs: move |req: &mut Request| main.rs: handlers::get_records(sdb_.clone(), req)); error: aborting due to previous error
sdb_, main - Iron . , , , - main, .
Rust . .
: sdb ?
let sdb_ = sdb.clone();
:
main.rs:125:36: 125:39 error: use of moved value: `sdb` [E0382] main.rs:125 let sdb_ = sdb.clone(); ^~~ main.rs:125:36: 125:39 help: run `rustc --explain E0382` to see a detailed explanation main.rs:119:29: 119:33 note: `sdb` moved here because it has type `alloc::arc::Arc<std::sync::mutex::Mutex<postgres::Connection>>`, which is moved by default main.rs:119 let sdb_ = sdb; ^~~~
. , , GET/id:
{ let sdb_ = sdb.clone(); router.get("/api/v1/records/:id", move |req: &mut Request| handlers::get_record(sdb_.clone(), req)); }
:id, Router', URL , .
HTTP- Router' :
Iron::new(router).http("localhost:3000").unwrap();
? ! , Rust. , - Mutex Arc.
- .
Arc<Mutex> . , .
, ? Rust |x| x + 1 - . - , . .
Fn? , Handler Iron' Fn:
impl<F> Handler for F where F: Send + Sync + Any + Fn(&mut Request) -> IronResult<Response> { fn handle(&self, req: &mut Request) -> IronResult<Response> { (*self)(req) } }
where - . , F, Send + Sync + Any + Fn(&mut Request) -> IronResult.
, Handler Fn. Iron, , : - , .
Rust! .
- move . move , , . move :
main.rs:121:36: 122:76 error: closure may outlive the current function, but it borrows `sdb_`, which is owned by the current function [E0373] main.rs:121 |req: &mut Request| main.rs:122 handlers::get_records(sdb_.clone(), req)); main.rs:121:36: 122:76 help: run `rustc --explain E0373` to see a detailed explanation main.rs:122:58: 122:62 note: `sdb_` is borrowed here main.rs:122 handlers::get_records(sdb_.clone(), req)); ^~~~ main.rs:121:36: 122:76 help: to force the closure to take ownership of `sdb_` (and any other referenced variables), use the `move` keyword, as shown: main.rs: move |req: &mut Request| main.rs: handlers::get_records(sdb_.clone(), req)); error: aborting due to previous error
sdb_, main - Iron . , , , - main, .
Rust . .
: sdb ?
let sdb_ = sdb.clone();
:
main.rs:125:36: 125:39 error: use of moved value: `sdb` [E0382] main.rs:125 let sdb_ = sdb.clone(); ^~~ main.rs:125:36: 125:39 help: run `rustc --explain E0382` to see a detailed explanation main.rs:119:29: 119:33 note: `sdb` moved here because it has type `alloc::arc::Arc<std::sync::mutex::Mutex<postgres::Connection>>`, which is moved by default main.rs:119 let sdb_ = sdb; ^~~~
. , , GET/id:
{ let sdb_ = sdb.clone(); router.get("/api/v1/records/:id", move |req: &mut Request| handlers::get_record(sdb_.clone(), req)); }
:id, Router', URL , .
HTTP- Router' :
Iron::new(router).http("localhost:3000").unwrap();
? ! , Rust. , - Mutex Arc.
- .
Arc<Mutex> . , .
, ? Rust |x| x + 1 - . - , . .
Fn? , Handler Iron' Fn:
impl<F> Handler for F where F: Send + Sync + Any + Fn(&mut Request) -> IronResult<Response> { fn handle(&self, req: &mut Request) -> IronResult<Response> { (*self)(req) } }
where - . , F, Send + Sync + Any + Fn(&mut Request) -> IronResult.
, Handler Fn. Iron, , : - , .
Rust! .
- move . move , , . move :
main.rs:121:36: 122:76 error: closure may outlive the current function, but it borrows `sdb_`, which is owned by the current function [E0373] main.rs:121 |req: &mut Request| main.rs:122 handlers::get_records(sdb_.clone(), req)); main.rs:121:36: 122:76 help: run `rustc --explain E0373` to see a detailed explanation main.rs:122:58: 122:62 note: `sdb_` is borrowed here main.rs:122 handlers::get_records(sdb_.clone(), req)); ^~~~ main.rs:121:36: 122:76 help: to force the closure to take ownership of `sdb_` (and any other referenced variables), use the `move` keyword, as shown: main.rs: move |req: &mut Request| main.rs: handlers::get_records(sdb_.clone(), req)); error: aborting due to previous error
sdb_, main - Iron . , , , - main, .
Rust . .
: sdb ?
let sdb_ = sdb.clone();
:
main.rs:125:36: 125:39 error: use of moved value: `sdb` [E0382] main.rs:125 let sdb_ = sdb.clone(); ^~~ main.rs:125:36: 125:39 help: run `rustc --explain E0382` to see a detailed explanation main.rs:119:29: 119:33 note: `sdb` moved here because it has type `alloc::arc::Arc<std::sync::mutex::Mutex<postgres::Connection>>`, which is moved by default main.rs:119 let sdb_ = sdb; ^~~~
. , , GET/id:
{ let sdb_ = sdb.clone(); router.get("/api/v1/records/:id", move |req: &mut Request| handlers::get_record(sdb_.clone(), req)); }
:id, Router', URL , .
HTTP- Router' :
Iron::new(router).http("localhost:3000").unwrap();
? ! , Rust. , - Mutex Arc.
- .
Arc<Mutex> . , .
, ? Rust |x| x + 1 - . - , . .
Fn? , Handler Iron' Fn:
impl<F> Handler for F where F: Send + Sync + Any + Fn(&mut Request) -> IronResult<Response> { fn handle(&self, req: &mut Request) -> IronResult<Response> { (*self)(req) } }
where - . , F, Send + Sync + Any + Fn(&mut Request) -> IronResult.
, Handler Fn. Iron, , : - , .
Rust! .
- move . move , , . move :
main.rs:121:36: 122:76 error: closure may outlive the current function, but it borrows `sdb_`, which is owned by the current function [E0373] main.rs:121 |req: &mut Request| main.rs:122 handlers::get_records(sdb_.clone(), req)); main.rs:121:36: 122:76 help: run `rustc --explain E0373` to see a detailed explanation main.rs:122:58: 122:62 note: `sdb_` is borrowed here main.rs:122 handlers::get_records(sdb_.clone(), req)); ^~~~ main.rs:121:36: 122:76 help: to force the closure to take ownership of `sdb_` (and any other referenced variables), use the `move` keyword, as shown: main.rs: move |req: &mut Request| main.rs: handlers::get_records(sdb_.clone(), req)); error: aborting due to previous error
sdb_, main - Iron . , , , - main, .
Rust . .
: sdb ?
let sdb_ = sdb.clone();
:
main.rs:125:36: 125:39 error: use of moved value: `sdb` [E0382] main.rs:125 let sdb_ = sdb.clone(); ^~~ main.rs:125:36: 125:39 help: run `rustc --explain E0382` to see a detailed explanation main.rs:119:29: 119:33 note: `sdb` moved here because it has type `alloc::arc::Arc<std::sync::mutex::Mutex<postgres::Connection>>`, which is moved by default main.rs:119 let sdb_ = sdb; ^~~~
. , , GET/id:
{ let sdb_ = sdb.clone(); router.get("/api/v1/records/:id", move |req: &mut Request| handlers::get_record(sdb_.clone(), req)); }
:id, Router', URL , .
HTTP- Router' :
Iron::new(router).http("localhost:3000").unwrap();
? ! , Rust. , - Mutex Arc.
- .
Arc<Mutex> . , .
, ? Rust |x| x + 1 - . - , . .
Fn? , Handler Iron' Fn:
impl<F> Handler for F where F: Send + Sync + Any + Fn(&mut Request) -> IronResult<Response> { fn handle(&self, req: &mut Request) -> IronResult<Response> { (*self)(req) } }
where - . , F, Send + Sync + Any + Fn(&mut Request) -> IronResult.
, Handler Fn. Iron, , : - , .
Rust! .
- move . move , , . move :
main.rs:121:36: 122:76 error: closure may outlive the current function, but it borrows `sdb_`, which is owned by the current function [E0373] main.rs:121 |req: &mut Request| main.rs:122 handlers::get_records(sdb_.clone(), req)); main.rs:121:36: 122:76 help: run `rustc --explain E0373` to see a detailed explanation main.rs:122:58: 122:62 note: `sdb_` is borrowed here main.rs:122 handlers::get_records(sdb_.clone(), req)); ^~~~ main.rs:121:36: 122:76 help: to force the closure to take ownership of `sdb_` (and any other referenced variables), use the `move` keyword, as shown: main.rs: move |req: &mut Request| main.rs: handlers::get_records(sdb_.clone(), req)); error: aborting due to previous error
sdb_, main - Iron . , , , - main, .
Rust . .
: sdb ?
let sdb_ = sdb.clone();
:
main.rs:125:36: 125:39 error: use of moved value: `sdb` [E0382] main.rs:125 let sdb_ = sdb.clone(); ^~~ main.rs:125:36: 125:39 help: run `rustc --explain E0382` to see a detailed explanation main.rs:119:29: 119:33 note: `sdb` moved here because it has type `alloc::arc::Arc<std::sync::mutex::Mutex<postgres::Connection>>`, which is moved by default main.rs:119 let sdb_ = sdb; ^~~~
. , , GET/id:
{ let sdb_ = sdb.clone(); router.get("/api/v1/records/:id", move |req: &mut Request| handlers::get_record(sdb_.clone(), req)); }
:id, Router', URL , .
HTTP- Router' :
Iron::new(router).http("localhost:3000").unwrap();
? ! , Rust. , - Mutex Arc.
- .
Arc<Mutex> . , .
, ? Rust |x| x + 1 - . - , . .
Fn? , Handler Iron' Fn:
impl<F> Handler for F where F: Send + Sync + Any + Fn(&mut Request) -> IronResult<Response> { fn handle(&self, req: &mut Request) -> IronResult<Response> { (*self)(req) } }
where - . , F, Send + Sync + Any + Fn(&mut Request) -> IronResult.
, Handler Fn. Iron, , : - , .
Rust! .
- move . move , , . move :
main.rs:121:36: 122:76 error: closure may outlive the current function, but it borrows `sdb_`, which is owned by the current function [E0373] main.rs:121 |req: &mut Request| main.rs:122 handlers::get_records(sdb_.clone(), req)); main.rs:121:36: 122:76 help: run `rustc --explain E0373` to see a detailed explanation main.rs:122:58: 122:62 note: `sdb_` is borrowed here main.rs:122 handlers::get_records(sdb_.clone(), req)); ^~~~ main.rs:121:36: 122:76 help: to force the closure to take ownership of `sdb_` (and any other referenced variables), use the `move` keyword, as shown: main.rs: move |req: &mut Request| main.rs: handlers::get_records(sdb_.clone(), req)); error: aborting due to previous error
sdb_, main - Iron . , , , - main, .
Rust . .
: sdb ?
let sdb_ = sdb.clone();
:
main.rs:125:36: 125:39 error: use of moved value: `sdb` [E0382] main.rs:125 let sdb_ = sdb.clone(); ^~~ main.rs:125:36: 125:39 help: run `rustc --explain E0382` to see a detailed explanation main.rs:119:29: 119:33 note: `sdb` moved here because it has type `alloc::arc::Arc<std::sync::mutex::Mutex<postgres::Connection>>`, which is moved by default main.rs:119 let sdb_ = sdb; ^~~~
. , , GET/id:
{ let sdb_ = sdb.clone(); router.get("/api/v1/records/:id", move |req: &mut Request| handlers::get_record(sdb_.clone(), req)); }
:id, Router', URL , .
HTTP- Router' :
Iron::new(router).http("localhost:3000").unwrap();
? ! , Rust. , - Mutex Arc.
- .
Arc<Mutex> . , .
, ? Rust |x| x + 1 - . - , . .
Fn? , Handler Iron' Fn:
impl<F> Handler for F where F: Send + Sync + Any + Fn(&mut Request) -> IronResult<Response> { fn handle(&self, req: &mut Request) -> IronResult<Response> { (*self)(req) } }
where - . , F, Send + Sync + Any + Fn(&mut Request) -> IronResult.
, Handler Fn. Iron, , : - , .
Rust! .
- move . move , , . move :
main.rs:121:36: 122:76 error: closure may outlive the current function, but it borrows `sdb_`, which is owned by the current function [E0373] main.rs:121 |req: &mut Request| main.rs:122 handlers::get_records(sdb_.clone(), req)); main.rs:121:36: 122:76 help: run `rustc --explain E0373` to see a detailed explanation main.rs:122:58: 122:62 note: `sdb_` is borrowed here main.rs:122 handlers::get_records(sdb_.clone(), req)); ^~~~ main.rs:121:36: 122:76 help: to force the closure to take ownership of `sdb_` (and any other referenced variables), use the `move` keyword, as shown: main.rs: move |req: &mut Request| main.rs: handlers::get_records(sdb_.clone(), req)); error: aborting due to previous error
sdb_, main - Iron . , , , - main, .
Rust . .
: sdb ?
let sdb_ = sdb.clone();
:
main.rs:125:36: 125:39 error: use of moved value: `sdb` [E0382] main.rs:125 let sdb_ = sdb.clone(); ^~~ main.rs:125:36: 125:39 help: run `rustc --explain E0382` to see a detailed explanation main.rs:119:29: 119:33 note: `sdb` moved here because it has type `alloc::arc::Arc<std::sync::mutex::Mutex<postgres::Connection>>`, which is moved by default main.rs:119 let sdb_ = sdb; ^~~~
. , , GET/id:
{ let sdb_ = sdb.clone(); router.get("/api/v1/records/:id", move |req: &mut Request| handlers::get_record(sdb_.clone(), req)); }
:id, Router', URL , .
HTTP- Router' :
Iron::new(router).http("localhost:3000").unwrap();
? ! , Rust. , - Mutex Arc.
- .
Arc<Mutex> . , .
, ? Rust |x| x + 1 - . - , . .
Fn? , Handler Iron' Fn:
impl<F> Handler for F where F: Send + Sync + Any + Fn(&mut Request) -> IronResult<Response> { fn handle(&self, req: &mut Request) -> IronResult<Response> { (*self)(req) } }
where - . , F, Send + Sync + Any + Fn(&mut Request) -> IronResult.
, Handler Fn. Iron, , : - , .
Rust! .
- move . move , , . move :
main.rs:121:36: 122:76 error: closure may outlive the current function, but it borrows `sdb_`, which is owned by the current function [E0373] main.rs:121 |req: &mut Request| main.rs:122 handlers::get_records(sdb_.clone(), req)); main.rs:121:36: 122:76 help: run `rustc --explain E0373` to see a detailed explanation main.rs:122:58: 122:62 note: `sdb_` is borrowed here main.rs:122 handlers::get_records(sdb_.clone(), req)); ^~~~ main.rs:121:36: 122:76 help: to force the closure to take ownership of `sdb_` (and any other referenced variables), use the `move` keyword, as shown: main.rs: move |req: &mut Request| main.rs: handlers::get_records(sdb_.clone(), req)); error: aborting due to previous error
sdb_, main - Iron . , , , - main, .
Rust . .
: sdb ?
let sdb_ = sdb.clone();
:
main.rs:125:36: 125:39 error: use of moved value: `sdb` [E0382] main.rs:125 let sdb_ = sdb.clone(); ^~~ main.rs:125:36: 125:39 help: run `rustc --explain E0382` to see a detailed explanation main.rs:119:29: 119:33 note: `sdb` moved here because it has type `alloc::arc::Arc<std::sync::mutex::Mutex<postgres::Connection>>`, which is moved by default main.rs:119 let sdb_ = sdb; ^~~~
. , , GET/id:
{ let sdb_ = sdb.clone(); router.get("/api/v1/records/:id", move |req: &mut Request| handlers::get_record(sdb_.clone(), req)); }
:id, Router', URL , .
HTTP- Router' :
Iron::new(router).http("localhost:3000").unwrap();
? ! , Rust. , - Mutex Arc.
- .
Arc<Mutex> . , .
, ? Rust |x| x + 1 - . - , . .
Fn? , Handler Iron' Fn:
impl<F> Handler for F where F: Send + Sync + Any + Fn(&mut Request) -> IronResult<Response> { fn handle(&self, req: &mut Request) -> IronResult<Response> { (*self)(req) } }
where - . , F, Send + Sync + Any + Fn(&mut Request) -> IronResult.
, Handler Fn. Iron, , : - , .
Rust! .
- move . move , , . move :
main.rs:121:36: 122:76 error: closure may outlive the current function, but it borrows `sdb_`, which is owned by the current function [E0373] main.rs:121 |req: &mut Request| main.rs:122 handlers::get_records(sdb_.clone(), req)); main.rs:121:36: 122:76 help: run `rustc --explain E0373` to see a detailed explanation main.rs:122:58: 122:62 note: `sdb_` is borrowed here main.rs:122 handlers::get_records(sdb_.clone(), req)); ^~~~ main.rs:121:36: 122:76 help: to force the closure to take ownership of `sdb_` (and any other referenced variables), use the `move` keyword, as shown: main.rs: move |req: &mut Request| main.rs: handlers::get_records(sdb_.clone(), req)); error: aborting due to previous error
sdb_, main - Iron . , , , - main, .
Rust . .
: sdb ?
let sdb_ = sdb.clone();
:
main.rs:125:36: 125:39 error: use of moved value: `sdb` [E0382] main.rs:125 let sdb_ = sdb.clone(); ^~~ main.rs:125:36: 125:39 help: run `rustc --explain E0382` to see a detailed explanation main.rs:119:29: 119:33 note: `sdb` moved here because it has type `alloc::arc::Arc<std::sync::mutex::Mutex<postgres::Connection>>`, which is moved by default main.rs:119 let sdb_ = sdb; ^~~~
. , , GET/id:
{ let sdb_ = sdb.clone(); router.get("/api/v1/records/:id", move |req: &mut Request| handlers::get_record(sdb_.clone(), req)); }
:id, Router', URL , .
HTTP- Router' :
Iron::new(router).http("localhost:3000").unwrap();
? ! , Rust. , - Mutex Arc.
- .
Arc<Mutex> . , .
, ? Rust |x| x + 1 - . - , . .
Fn? , Handler Iron' Fn:
impl<F> Handler for F where F: Send + Sync + Any + Fn(&mut Request) -> IronResult<Response> { fn handle(&self, req: &mut Request) -> IronResult<Response> { (*self)(req) } }
where - . , F, Send + Sync + Any + Fn(&mut Request) -> IronResult.
, Handler Fn. Iron, , : - , .
Rust! .
- move . move , , . move :
main.rs:121:36: 122:76 error: closure may outlive the current function, but it borrows `sdb_`, which is owned by the current function [E0373] main.rs:121 |req: &mut Request| main.rs:122 handlers::get_records(sdb_.clone(), req)); main.rs:121:36: 122:76 help: run `rustc --explain E0373` to see a detailed explanation main.rs:122:58: 122:62 note: `sdb_` is borrowed here main.rs:122 handlers::get_records(sdb_.clone(), req)); ^~~~ main.rs:121:36: 122:76 help: to force the closure to take ownership of `sdb_` (and any other referenced variables), use the `move` keyword, as shown: main.rs: move |req: &mut Request| main.rs: handlers::get_records(sdb_.clone(), req)); error: aborting due to previous error
sdb_, main - Iron . , , , - main, .
Rust . .
: sdb ?
let sdb_ = sdb.clone();
:
main.rs:125:36: 125:39 error: use of moved value: `sdb` [E0382] main.rs:125 let sdb_ = sdb.clone(); ^~~ main.rs:125:36: 125:39 help: run `rustc --explain E0382` to see a detailed explanation main.rs:119:29: 119:33 note: `sdb` moved here because it has type `alloc::arc::Arc<std::sync::mutex::Mutex<postgres::Connection>>`, which is moved by default main.rs:119 let sdb_ = sdb; ^~~~
. , , GET/id:
{ let sdb_ = sdb.clone(); router.get("/api/v1/records/:id", move |req: &mut Request| handlers::get_record(sdb_.clone(), req)); }
:id, Router', URL , .
HTTP- Router' :
Iron::new(router).http("localhost:3000").unwrap();
? ! , Rust. , - Mutex Arc.
- .
Arc<Mutex> . , .
, ? Rust |x| x + 1 - . - , . .
Fn? , Handler Iron' Fn:
impl<F> Handler for F where F: Send + Sync + Any + Fn(&mut Request) -> IronResult<Response> { fn handle(&self, req: &mut Request) -> IronResult<Response> { (*self)(req) } }
where - . , F, Send + Sync + Any + Fn(&mut Request) -> IronResult.
, Handler Fn. Iron, , : - , .
Rust! .
- move . move , , . move :
main.rs:121:36: 122:76 error: closure may outlive the current function, but it borrows `sdb_`, which is owned by the current function [E0373] main.rs:121 |req: &mut Request| main.rs:122 handlers::get_records(sdb_.clone(), req)); main.rs:121:36: 122:76 help: run `rustc --explain E0373` to see a detailed explanation main.rs:122:58: 122:62 note: `sdb_` is borrowed here main.rs:122 handlers::get_records(sdb_.clone(), req)); ^~~~ main.rs:121:36: 122:76 help: to force the closure to take ownership of `sdb_` (and any other referenced variables), use the `move` keyword, as shown: main.rs: move |req: &mut Request| main.rs: handlers::get_records(sdb_.clone(), req)); error: aborting due to previous error
sdb_, main - Iron . , , , - main, .
Rust . .
: sdb ?
let sdb_ = sdb.clone();
:
main.rs:125:36: 125:39 error: use of moved value: `sdb` [E0382] main.rs:125 let sdb_ = sdb.clone(); ^~~ main.rs:125:36: 125:39 help: run `rustc --explain E0382` to see a detailed explanation main.rs:119:29: 119:33 note: `sdb` moved here because it has type `alloc::arc::Arc<std::sync::mutex::Mutex<postgres::Connection>>`, which is moved by default main.rs:119 let sdb_ = sdb; ^~~~
. , , GET/id:
{ let sdb_ = sdb.clone(); router.get("/api/v1/records/:id", move |req: &mut Request| handlers::get_record(sdb_.clone(), req)); }
:id, Router', URL , .
HTTP- Router' :
Iron::new(router).http("localhost:3000").unwrap();
? ! , Rust. , - Mutex Arc.
- .
Source: https://habr.com/ru/post/268617/
All Articles