diff --git a/src/cursor.rs b/src/cursor.rs index 3261640..9b799b8 100644 --- a/src/cursor.rs +++ b/src/cursor.rs @@ -1,5 +1,5 @@ use libc::{c_void, size_t, c_uint}; -use std::{mem, ptr, raw}; +use std::{ptr, slice}; use std::marker::{PhantomData, PhantomFn}; use database::Database; @@ -206,10 +206,7 @@ unsafe fn slice_to_val(slice: Option<&[u8]>) -> ffi::MDB_val { } unsafe fn val_to_slice<'a>(val: ffi::MDB_val) -> &'a [u8] { - mem::transmute(raw::Slice { - data: val.mv_data as *const u8, - len: val.mv_size as usize - }) + slice::from_raw_parts(val.mv_data as *const u8, val.mv_size as usize) } pub struct Iter<'txn> { diff --git a/src/lib.rs b/src/lib.rs index 4886467..06dc2f4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,7 @@ //! Idiomatic and safe APIs for interacting with the //! [Symas Lightning Memory-Mapped Database (LMDB)](http://symas.com/mdb/). -#![feature(core, libc, optin_builtin_traits, unsafe_destructor)] +#![feature(libc, optin_builtin_traits, unsafe_destructor)] #![cfg_attr(test, feature(std_misc, test))] extern crate libc; diff --git a/src/transaction.rs b/src/transaction.rs index 7e74130..cf045ee 100644 --- a/src/transaction.rs +++ b/src/transaction.rs @@ -1,5 +1,5 @@ use libc::{c_uint, c_void, size_t}; -use std::{mem, ptr, raw}; +use std::{mem, ptr, slice}; use std::marker::{PhantomData, PhantomFn} ; use ffi; @@ -77,10 +77,8 @@ pub trait TransactionExt<'env> : Transaction<'env> + Sized { unsafe { match ffi::mdb_get(self.txn(), database.dbi(), &mut key_val, &mut data_val) { ffi::MDB_SUCCESS => { - Ok(mem::transmute(raw::Slice { - data: data_val.mv_data as *const u8, - len: data_val.mv_size as usize - })) + Ok(slice::from_raw_parts(data_val.mv_data as *const u8, + data_val.mv_size as usize)) }, err_code => Err(Error::from_err_code(err_code)), } @@ -290,10 +288,8 @@ impl <'env> RwTransaction<'env> { &mut key_val, &mut data_val, flags.bits() | ffi::MDB_RESERVE))); - Ok(mem::transmute(raw::Slice { - data: data_val.mv_data as *const u8, - len: data_val.mv_size as usize - })) + Ok(slice::from_raw_parts_mut(data_val.mv_data as *mut u8, + data_val.mv_size as usize)) } }