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
fnmain(){let a = Some(vec![1,2,3,4]);let b :&Option<Vec<u8>> = &a;let c :Option<&[u8]>;// c = b; // expected enum `std::option::Option`, found reference// c = *b; // expected &[u8], found struct `std::vec::Vec`// c = (*b).map(|x|x.as_slice()); // cannot move `b` out of borrowed content// c = b.map(|x|x.as_slice()); // cannot move `b` out of borrowed content and `x` does not live long enough// Ask IRC here
c = b.as_ref().map(|x|x.as_slice());let _ = c;}
Compiler message should hint Option::as_ref, to shift user attention from object inside Option to the Option itself.