Trait see_through::See

source ·
pub trait See<N> {
    type Inner;

    // Required methods
    fn get(&self) -> &Self::Inner;
    fn set(&mut self) -> &mut Self::Inner;
}
Expand description

This trait let’s us visit a specific field inside a struct. similar to lens in Haskell

e.g. Consider a scenerio where, you are passing a generic to a function and incidentally you also want to get a value inside it. Let’s assume that there are multiple structs with the same field foo you might wish to for example view it. But, it would be impossible to do so,

Required Associated Types§

source

type Inner

This is the type of the value that we want to See

Required Methods§

source

fn get(&self) -> &Self::Inner

By using &self get the internal value Inner

source

fn set(&mut self) -> &mut Self::Inner

If we have access to &mut self try and mutate &mut Inner

Implementors§