diff --git a/stainless_frontend/tests/pass/mut_ref_borrow_11.rs b/stainless_frontend/tests/pass/mut_ref_borrow_11.rs index d20ecc80..313e301a 100644 --- a/stainless_frontend/tests/pass/mut_ref_borrow_11.rs +++ b/stainless_frontend/tests/pass/mut_ref_borrow_11.rs @@ -1,51 +1,16 @@ extern crate stainless; -/// This benchmark stems from [RustVis Specs](http://erik.vestera.as/rustvis/specs) -/// and was adapted to work with stainless. - -struct Container { - pair: Option<(K, V)>, -} - -impl Container { - pub fn new() -> Self { - Container { pair: None } - } - - pub fn insert(&mut self, k: K, v: V) { - self.pair = Some((k, v)) - } -} - -impl Container { - pub fn get_mut(&mut self, key: &String) -> Option<&mut V> { - match &mut self.pair { - Some((k, v)) if *k == *key => Some(v), - _ => None, - } +#[allow(unused_mut, unused_assignments)] +fn change(mut opt: Option<&mut i32>) { + if let Some(x) = opt { + *x = 456; } + opt = None; } pub fn main() { - let mut target = Container::new(); - let key = "foo".to_string(); - - let ref1 = &mut target; - match ref1.get_mut(&key) { - Some(value) => *value = 123, - _ => { - target.insert(key.clone(), 5); - match target.get_mut(&key) { - Some(v) => *v = 123, - _ => panic!("no value"), - } - } - } - - assert!(matches!( - target, - Container { - pair: Some((key, 123)) - } if key == "foo" - )) + let mut x = 123; + change(None); + change(Some(&mut x)); + assert!(x == 456) }