1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
10 fn some_func(a: Option<u32>) -> Option<u32> {
18 fn some_other_func(a: Option<u32>) -> Option<u32> {
27 pub enum SeemsOption<T> {
32 impl<T> SeemsOption<T> {
33 pub fn is_none(&self) -> bool {
35 SeemsOption::None => true,
36 SeemsOption::Some(_) => false,
41 fn returns_something_similar_to_option(a: SeemsOption<u32>) -> SeemsOption<u32> {
43 return SeemsOption::None;
49 pub struct CopyStruct {
55 pub fn func(&self) -> Option<u32> {
56 if (self.opt).is_none() {
60 if self.opt.is_none() {
64 let _ = if self.opt.is_none() {
75 pub struct MoveStruct {
76 pub opt: Option<Vec<u32>>,
80 pub fn ref_func(&self) -> Option<Vec<u32>> {
81 if self.opt.is_none() {
88 pub fn mov_func_reuse(self) -> Option<Vec<u32>> {
89 if self.opt.is_none() {
96 pub fn mov_func_no_use(self) -> Option<Vec<u32>> {
97 if self.opt.is_none() {
108 let copy_struct = CopyStruct { opt: Some(54) };
111 let move_struct = MoveStruct {
112 opt: Some(vec![42, 1337]),
114 move_struct.ref_func();
115 move_struct.clone().mov_func_reuse();
116 move_struct.clone().mov_func_no_use();
118 let so = SeemsOption::Some(45);
119 returns_something_similar_to_option(so);