34 lines
388 B
Plaintext
34 lines
388 B
Plaintext
|
|
fn change_to(place: *mut int, value: int)
|
|
{
|
|
*place = value;
|
|
}
|
|
|
|
fn main()
|
|
{
|
|
let a = 1;
|
|
let b: *int = &a;
|
|
|
|
// expect: 1
|
|
print_int(*b);
|
|
|
|
a = 2;
|
|
|
|
// expect: 2
|
|
print_int(*b);
|
|
|
|
let c: *mut int = &mut a;
|
|
*c = 3;
|
|
|
|
// expect: 3
|
|
print_int(a);
|
|
// expect: 3
|
|
print_int(*c);
|
|
|
|
change_to(&mut a, 4);
|
|
|
|
// expect: 4
|
|
print_int(a);
|
|
}
|
|
|