Skip to content

Instantly share code, notes, and snippets.

@drhodes
Created May 9, 2013 15:48
Show Gist options
  • Save drhodes/5548317 to your computer and use it in GitHub Desktop.
Save drhodes/5548317 to your computer and use it in GitHub Desktop.
enum Shape {
Circle {
radius: float
},
NoShape,
}
fn main() {
let mut c = Circle{radius: 5.0};
match c {
x@Circle{_} => {
x.radius = 0.0;
// ERROR
// main.rs:14:12: 14:20 error: attempted access of field
// `radius` on type `Shape`, but no field with that
// name was found
// main.rs:14 x.radius = 0.0
// ^~~~~~~~
},
NoShape => (),
}
}
@drhodes
Copy link
Author

drhodes commented May 9, 2013

This is precisely the same error reported when attempting to mutate radius on c:
c.radius = 0.0;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment