1 // Copyright (C) 2016-2023 Free Software Foundation, Inc.
3 // This program is free software; you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation; either version 3 of the License, or
6 // (at your option) any later version.
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #![allow(unused_variables)]
18 #![allow(unused_assignments)]
22 fn whatever(&self) -> i32;
23 fn static_i32(x: i32) -> Self;
26 impl Whatever for i32 {
27 fn whatever(&self) -> i32 {
28 *self // set breakpoint 2 here
31 fn static_i32(x: i32) -> i32 {
36 pub struct HasMethods {
41 pub fn new() -> HasMethods {
42 HasMethods { value: 0 }
45 pub fn incr(&mut self) -> &mut HasMethods {
50 pub fn take(self) -> HasMethods {
55 impl Whatever for HasMethods {
56 fn whatever(&self) -> i32 {
60 fn static_i32(x: i32) -> HasMethods {
73 fn value(&self) -> i32 {
75 SomeEnum::Three(x) => x,
76 SomeEnum::Four{x} => x,
81 fn mut_value(&mut self) -> i32 {
83 SomeEnum::Three(x) => x,
84 SomeEnum::Four{x} => x,
89 fn take_value(self) -> (i32, SomeEnum) {
91 SomeEnum::Three(x) => x,
92 SomeEnum::Four{x} => x,
105 fn value(&self) -> i32 {
107 SimpleEnum::One => 1,
108 SimpleEnum::Two => 2,
109 SimpleEnum::Three => 452,
115 let mut a = SomeEnum::Three(23);
117 let amv = (&mut a).mut_value();
118 let atv = a.take_value();
119 let b = SomeEnum::Four{x: 24};
121 let c = SimpleEnum::Three;
123 let mut x = HasMethods::new();
124 x.incr(); // set breakpoint 1 here
126 let y = 23i32.whatever();