Skip to main content

lens

Macro lens 

Source
macro_rules! lens {
    ($($model:ident)::+ . $($field:ident).+) => { ... };
}
Expand description

Build a Lens from a model and a field, or a chain of embedded fields.

lens!(User.name) is the path User::fields().name() paired with |user| &user.name. A chain through a relation does not compile: a relation’s records are not part of the row.

lens!(User.name)          // Lens<User, String>
lens!(Post.seo.title)     // an embedded struct's field
lens!(crate::blog::Post.title)