Making DB.create_cf generic...

master
Jordan Terrell 6 years ago
parent 47cd7ffe6b
commit 562f413f4c
  1. 6
      src/db.rs

@ -1027,8 +1027,8 @@ impl DB {
self.get_pinned_cf_opt(cf, key, &ReadOptions::default()) self.get_pinned_cf_opt(cf, key, &ReadOptions::default())
} }
pub fn create_cf(&self, name: &str, opts: &Options) -> Result<ColumnFamily, Error> { pub fn create_cf<N: AsRef<str>>(&self, name: N, opts: &Options) -> Result<ColumnFamily, Error> {
let cname = match CString::new(name.as_bytes()) { let cname = match CString::new(name.as_ref().as_bytes()) {
Ok(c) => c, Ok(c) => c,
Err(_) => { Err(_) => {
return Err(Error::new( return Err(Error::new(
@ -1048,7 +1048,7 @@ impl DB {
self.cfs self.cfs
.write() .write()
.map_err(|e| Error::new(e.to_string()))? .map_err(|e| Error::new(e.to_string()))?
.insert(name.to_string(), cf_handle); .insert(name.as_ref().to_string(), cf_handle);
ColumnFamily { ColumnFamily {
inner: cf_handle, inner: cf_handle,

Loading…
Cancel
Save