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

Loading…
Cancel
Save