2 #![allow(unreachable_code)]
4 #![allow(clippy::unnecessary_wraps)]
6 fn some_func(a: Option<u32>) -> Option<u32> {
14 fn some_other_func(a: Option<u32>) -> Option<u32> {
23 pub enum SeemsOption<T> {
28 impl<T> SeemsOption<T> {
29 pub fn is_none(&self) -> bool {
31 SeemsOption::None => true,
32 SeemsOption::Some(_) => false,
37 fn returns_something_similar_to_option(a: SeemsOption<u32>) -> SeemsOption<u32> {
39 return SeemsOption::None;
45 pub struct CopyStruct {
51 pub fn func(&self) -> Option<u32> {
52 if (self.opt).is_none() {
56 if self.opt.is_none() {
60 let _ = if self.opt.is_none() {
66 let _ = if let Some(x) = self.opt {
77 pub struct MoveStruct {
78 pub opt: Option<Vec<u32>>,
82 pub fn ref_func(&self) -> Option<Vec<u32>> {
83 if self.opt.is_none() {
90 pub fn mov_func_reuse(self) -> Option<Vec<u32>> {
91 if self.opt.is_none() {
98 pub fn mov_func_no_use(self) -> Option<Vec<u32>> {
99 if self.opt.is_none() {
105 pub fn if_let_ref_func(self) -> Option<Vec<u32>> {
106 let v: &Vec<_> = if let Some(ref v) = self.opt {
115 pub fn if_let_mov_func(self) -> Option<Vec<u32>> {
116 let v = if let Some(v) = self.opt {
126 fn func() -> Option<i32> {
127 fn f() -> Option<String> {
138 fn func_returning_result() -> Result<i32, i32> {
142 fn result_func(x: Result<i32, i32>) -> Result<i32, i32> {
143 let _ = if let Ok(x) = x { x } else { return x };
150 let y = if let Ok(x) = x {
158 let _ = if let Ok(x) = func_returning_result() {
165 if func_returning_result().is_err() {
166 return func_returning_result();
179 fn obj(_: i32) -> Result<(), NotOption> {
180 Err(NotOption::First)
183 fn f() -> NotOption {
185 return NotOption::None;
192 fn err_immediate_return() -> Result<i32, i32> {
193 if let Err(err) = func_returning_result() {
199 fn err_immediate_return_and_do_something() -> Result<i32, i32> {
200 if let Err(err) = func_returning_result() {
208 fn no_immediate_return() -> Result<i32, i32> {
209 if let Err(err) = func_returning_result() {
217 fn mixed_result_and_option() -> Option<i32> {
218 if let Err(err) = func_returning_result() {
225 fn else_if_check() -> Result<i32, i32> {
228 } else if let Err(e) = func_returning_result() {
236 #[allow(clippy::manual_map)]
238 fn option_map() -> Option<bool> {
239 if let Some(a) = Some(false) {