Fix lifetime issue in options

pull/4/head
Thijs Cadier 9 years ago
parent 494914c638
commit 87e4f3cb8b

@ -241,6 +241,10 @@ impl<'a> Collection<'a> {
let default_options = CountOptions::default(); let default_options = CountOptions::default();
let options = options.unwrap_or(&default_options); let options = options.unwrap_or(&default_options);
let opts_bsonc = match options.opts {
Some(ref o) => Some(try!(Bsonc::from_document(o))),
None => None
};
let mut error = BsoncError::empty(); let mut error = BsoncError::empty();
let count = unsafe { let count = unsafe {
@ -250,8 +254,8 @@ impl<'a> Collection<'a> {
try!(Bsonc::from_document(query)).inner(), try!(Bsonc::from_document(query)).inner(),
options.skip as i64, options.skip as i64,
options.limit as i64, options.limit as i64,
match options.opts { match opts_bsonc {
Some(ref o) => try!(Bsonc::from_document(o)).inner(), Some(ref o) => o.inner(),
None => ptr::null() None => ptr::null()
}, },
match options.read_prefs { match options.read_prefs {

@ -127,12 +127,17 @@ impl<'a> Database<'a> {
let mut error = BsoncError::empty(); let mut error = BsoncError::empty();
let name_cstring = CString::new(name).unwrap(); let name_cstring = CString::new(name).unwrap();
let options_bsonc = match options {
Some(o) => Some(try!(Bsonc::from_document(o))),
None => None
};
let coll = unsafe { let coll = unsafe {
bindings::mongoc_database_create_collection( bindings::mongoc_database_create_collection(
self.inner, self.inner,
name_cstring.as_ptr(), name_cstring.as_ptr(),
match options { match options_bsonc {
Some(o) => try!(Bsonc::from_document(o)).inner(), Some(ref o) => o.inner(),
None => ptr::null() None => ptr::null()
}, },
error.mut_inner() error.mut_inner()

Loading…
Cancel
Save