1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
/// ## Example /// /// A row with field `a: String` /// /// ```rust /// fn with_field_a(r: row! { a: String, .. }) -> String { /// r.view(optics!(a)) /// } /// /// fn to_field_a() -> row! { a: String, .. } { /// Bar { /// a: "this is Bar".to_string(), /// c: 0, /// } /// } /// /// let foo = Foo { /// a: "this is Foo".to_string(), /// b: (), /// }; /// let bar = Bar { /// a: "this is Bar".to_string(), /// c: 0, /// }; /// /// assert_eq!(with_field_a(foo.clone()).as_str(), "this is Foo"); /// assert_eq!(with_field_a(bar.clone()).as_str(), "this is Bar"); /// ``` /// /// A row may have field `Some: String` /// /// ```rust /// row! { Some: String?, .. } /// dyn_row! { Some: String?, .. } // dynamic version of row! /// ``` /// /// A row have multiple fields `_mapped: String` /// /// ```rust /// row! { _mapped: String*, .. } /// dyn_row! { _mapped: String*, .. } /// ``` /// /// A row with a mutable or immutable field: /// /// ```rust /// row! { ref a: A, mut b: B, .. } /// dyn_row! { ref a: A, mut b: B, .. } /// ``` /// /// A row bound by lifetimes `'a` /// /// ```rust /// row! { <'a> ref a: A, mut b: B, .. } /// dyn_row! { <'a> ref a: A, mut b: B, .. } /// ``` /// /// In fact, /// /// * `row! { <'a> ref a: A, mut b: B, c: C, .. }` is `impl LensRef<Optic![a], Image = A> + LensMut<Optic![b], Image = B> + Lens<Optic![c], Image = C> + 'a` /// * `dyn_row! { <'a> ref a: A, mut b: B, c: C, .. }` is `dyn LensRef<Optic![a], Image = A> + LensMut<Optic![b], Image = B> + Lens<Optic![c], Image = C> + 'a` pub use rovv_derive::{dyn_row, row}; pub trait Empty {} impl<T> Empty for T {} use lens_rs; include!(concat!(env!("OUT_DIR"), "/dyn_row.rs"));