Files
rust/tests/ui/fn/mutable-function-parameters.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

25 lines
387 B
Rust
Raw Normal View History

2025-06-29 21:05:19 +05:00
//! Test that function and closure parameters marked as `mut` can be mutated
//! within the function body.
//@ run-pass
fn f(mut y: Box<isize>) {
*y = 5;
assert_eq!(*y, 5);
}
fn g() {
2025-06-29 21:05:19 +05:00
let frob = |mut q: Box<isize>| {
*q = 2;
assert_eq!(*q, 2);
};
let w = Box::new(37);
frob(w);
}
pub fn main() {
let z = Box::new(17);
f(z);
g();
}