|
@@ -1,5 +1,17 @@
|
|
|
use crate::{Walkable, Walker};
|
|
|
|
|
|
+impl<'a, T: Walkable> Walkable for &'a T {
|
|
|
+ fn walk_with<W: Walker>(walker: &mut W) {
|
|
|
+ walker.visit_ref::<T>()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+impl<'a, T: Walkable> Walkable for &'a mut T {
|
|
|
+ fn walk_with<W: Walker>(walker: &mut W) {
|
|
|
+ walker.visit_ref::<T>()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
impl Walkable for u8 {
|
|
|
fn walk_with<W: Walker>(walker: &mut W) {
|
|
|
walker.visit_integer(crate::IntegerType::u8)
|
|
@@ -54,6 +66,12 @@ impl Walkable for usize {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+impl<'l> Walkable for &'l str {
|
|
|
+ fn walk_with<W: Walker>(walker: &mut W) {
|
|
|
+ walker.visit_str()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
impl<T: Walkable> Walkable for Option<T> {
|
|
|
fn walk_with<W: Walker>(walker: &mut W) {
|
|
|
walker.visit_option::<T>()
|
|
@@ -127,3 +145,58 @@ impl<T0: Walkable, T1: Walkable, T2: Walkable, T3: Walkable> Walkable for (T0, T
|
|
|
walker.visit_tuple::<Tuple<(T0, T1, T2, T3)>>();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+impl<T: Walkable, const LEN: usize> Walkable for [T;LEN] {
|
|
|
+ fn walk_with<W: Walker>(walker: &mut W) {
|
|
|
+ walker.visit_array::<T>(LEN);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+impl<'l, T: Walkable> Walkable for &'l [T] {
|
|
|
+ fn walk_with<W: Walker>(walker: &mut W) {
|
|
|
+ walker.visit_slice::<T>();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+#[cfg(feature = "std")]
|
|
|
+mod std_types {
|
|
|
+ use crate::StdType;
|
|
|
+
|
|
|
+ use super::{Walker,Walkable};
|
|
|
+
|
|
|
+ impl Walkable for String {
|
|
|
+ fn walk_with<W: Walker>(walker: &mut W) {
|
|
|
+ walker.visit_str()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ impl<T: Walkable> Walkable for Vec<T> {
|
|
|
+ fn walk_with<W: Walker>(walker: &mut W) {
|
|
|
+ walker.visit_vec::<T>()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ impl<T: Walkable> Walkable for std::rc::Rc<T> {
|
|
|
+ fn walk_with<W: Walker>(walker: &mut W) {
|
|
|
+ walker.visit_std_type::<T>(StdType::Rc)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ impl<T: Walkable> Walkable for std::sync::Arc<T> {
|
|
|
+ fn walk_with<W: Walker>(walker: &mut W) {
|
|
|
+ walker.visit_std_type::<T>(StdType::Arc)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ impl<T: Walkable> Walkable for std::cell::Cell<T> {
|
|
|
+ fn walk_with<W: Walker>(walker: &mut W) {
|
|
|
+ walker.visit_std_type::<T>(StdType::Cell)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ impl<T: Walkable> Walkable for std::cell::RefCell<T> {
|
|
|
+ fn walk_with<W: Walker>(walker: &mut W) {
|
|
|
+ walker.visit_std_type::<T>(StdType::RefCell)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|