Skip to content

Commit 78cfeae

Browse files
committed
Implement Source for Rc
1 parent df6eadc commit 78cfeae

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/kv/source.rs

+18
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ mod std_support {
225225
use std::borrow::Borrow;
226226
use std::collections::{BTreeMap, HashMap};
227227
use std::hash::{BuildHasher, Hash};
228+
use std::rc::Rc;
228229
use std::sync::Arc;
229230

230231
impl<S> Source for Box<S>
@@ -261,6 +262,23 @@ mod std_support {
261262
}
262263
}
263264

265+
impl<S> Source for Rc<S>
266+
where
267+
S: Source + ?Sized,
268+
{
269+
fn visit<'kvs>(&'kvs self, visitor: &mut dyn Visitor<'kvs>) -> Result<(), Error> {
270+
Source::visit(&**self, visitor)
271+
}
272+
273+
fn get(&self, key: Key) -> Option<Value<'_>> {
274+
Source::get(&**self, key)
275+
}
276+
277+
fn count(&self) -> usize {
278+
Source::count(&**self)
279+
}
280+
}
281+
264282
impl<S> Source for Vec<S>
265283
where
266284
S: Source,

0 commit comments

Comments
 (0)