2 #![allow(unreachable_code)]
4 fn some_func(a: Option<u32>) -> Option<u32> {
10 fn some_other_func(a: Option<u32>) -> Option<u32> {
19 pub enum SeemsOption<T> {
24 impl<T> SeemsOption<T> {
25 pub fn is_none(&self) -> bool {
27 SeemsOption::None => true,
28 SeemsOption::Some(_) => false,
33 fn returns_something_similar_to_option(a: SeemsOption<u32>) -> SeemsOption<u32> {
35 return SeemsOption::None;
41 pub struct CopyStruct {
47 pub fn func(&self) -> Option<u32> {
52 let _ = Some(self.opt?);
61 pub struct MoveStruct {
62 pub opt: Option<Vec<u32>>,
66 pub fn ref_func(&self) -> Option<Vec<u32>> {
72 pub fn mov_func_reuse(self) -> Option<Vec<u32>> {
78 pub fn mov_func_no_use(self) -> Option<Vec<u32>> {
83 pub fn if_let_ref_func(self) -> Option<Vec<u32>> {
84 let v: &Vec<_> = self.opt.as_ref()?;
89 pub fn if_let_mov_func(self) -> Option<Vec<u32>> {
96 fn func() -> Option<i32> {
97 fn f() -> Option<String> {
109 some_other_func(Some(42));
111 let copy_struct = CopyStruct { opt: Some(54) };
114 let move_struct = MoveStruct {
115 opt: Some(vec![42, 1337]),
117 move_struct.ref_func();
118 move_struct.clone().mov_func_reuse();
119 move_struct.mov_func_no_use();
121 let so = SeemsOption::Some(45);
122 returns_something_similar_to_option(so);