You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pub type MoveList<M> = Option<Box<MoveNode<M>>>;
pub struct MoveNode<M> {
m: M,
n: MoveList<M>
}
pub fn pop_front<M>(ml: MoveList<M>) -> (Option<M>, MoveList<M>) {
match ml {
None => (None, None),
Some(box MoveNode { m, n }) => (Some(m), n)
}
}
produces the error message “error: use of collaterally moved value” pointing to the second match arm. See http://is.gd/kBotGl -- tested on 2015-01-16 again: same result.
But when the destructuring is split in two parts, it works:
pub fn pop_front<M>(ml: MoveList<M>) -> (Option<M>, MoveList<M>) {
match ml {
None => (None, None),
Some(box ml) => {
let MoveNode {m, n} = ml;
(Some(m), n)
}
}
}