Skip to content

Commit

Permalink
Change lens! to use move semantics.
Browse files Browse the repository at this point in the history
This allows passing a variables and not just constants for indexing arrays.
  • Loading branch information
luleyleo committed Sep 3, 2020
1 parent f827c57 commit b1905b8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions druid/src/lens/lens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,10 @@ where
#[macro_export]
macro_rules! lens {
($ty:ty, [$index:expr]) => {
$crate::lens::Field::new::<$ty, _>(|x| &x[$index], |x| &mut x[$index])
$crate::lens::Field::new::<$ty, _>(move |x| &x[$index], move |x| &mut x[$index])
};
($ty:ty, $field:tt) => {
$crate::lens::Field::new::<$ty, _>(|x| &x.$field, |x| &mut x.$field)
$crate::lens::Field::new::<$ty, _>(move |x| &x.$field, move |x| &mut x.$field)
};
}

Expand Down

0 comments on commit b1905b8

Please sign in to comment.