Trait Access
Source pub trait Access<T> {
// Required methods
fn get(&self) -> T;
fn set(&mut self, new_value: T);
// Provided method
fn map<B, F, I>(self, from: F, into: I) -> MapAccess<Self, F, I>
where Self: Sized,
F: Fn(T) -> B,
I: Fn(B) -> T { ... }
}
3fn main() {
4 let mut int = 0;
5 let mut string_access = RefAccess::new(&mut int).map(|i| i.to_string(), |s| s.parse().unwrap());
6
7 println!("string: {}", string_access.get());
8 string_access.set("42".to_string());
9 println!("string: {}", string_access.get());
10 println!("int: {}", int);
11}