[−][src]Crate ref_clone
This crate provides an implementation of a borrow as a higher kinded type.
This can be used to abstract over the type of borrow by passing the type of the borrow as a type argument.
Example:
#[RefAccessors] struct Example { pub value: u8, } fn get_example_value<'a, T: RefType>(x: Ref<'a, Example, T>) -> Ref<'a, u8, T> { let x = x.to_wrapped(); x.value } fn main() { let mut ex = Example { value: 8 }; { let ex_ref = Shared::new(&ex); println!("{}", get_example_value(ex_ref)); // = 8 } { let ex_mut = Unique::new(&mut ex); *get_example_value(ex_mut).as_mut() = 1; } println!("{}", ex.value); // = 1 { let ex_ref = Shared::new(&ex); println!("{}", get_example_value(ex_ref)); // = 1 } }
Structs
Ref | The Ref type. Third type parameter is the type of the Borrow. |
RefFn | A data structure to allow choosing either of |
RefIter | |
RefIterator | |
Shared | Shared Reference type. |
Unique | Unique Reference type. |
Traits
DerefRef | |
IndexRef | |
IntoIteratorRef | |
IntoRef | |
RefAccessors | |
RefType | The type of the borrow. |
Attribute Macros
RefAccessors |