// SPDX-License-Identifier: Apache-2.0 OR MIT // // Modifications Copyright Kani Contributors // See GitHub history for details. //! This test is to check how Kani handle some std functions. The original issue was: //! //! This code was extracted from Rust by Example book. trait UsernameWidget { // Get the selected username out of this widget fn get(&self) -> String; } trait AgeWidget { // Get the selected age out of this widget fn get(&self) -> u8; } // A form with both a UsernameWidget and an AgeWidget struct Form { username: String, age: u8, } impl UsernameWidget for Form { fn get(&self) -> String { self.username.clone() } } impl AgeWidget for Form { fn get(&self) -> u8 { self.age } } #[kani::proof] pub fn main() { let form = Form { username: "rustacean".to_owned(), age: 28 }; // If you uncomment this line, you'll get an error saying // "multiple `get` found". Because, after all, there are multiple methods // named `get`. // println!("{}", form.get()); let username =
::get(&form); assert_eq!("rustacean".to_owned(), username); let age = ::get(&form); assert_eq!(28, age); }