Created
April 13, 2013 04:59
-
-
Save SiegeLord/5377002 to your computer and use it in GitHub Desktop.
Inherited mutability
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct c_struct; | |
| unsafe fn c_function(a : *mut c_struct) | |
| { | |
| } | |
| struct wrapper | |
| { | |
| payload : *c_struct | |
| } | |
| fn create() -> wrapper | |
| { | |
| unsafe | |
| { | |
| wrapper{payload : ptr::null()} | |
| } | |
| } | |
| fn function(a : &mut wrapper) | |
| { | |
| unsafe | |
| { | |
| c_function(a.payload); | |
| } | |
| } | |
| fn main() | |
| { | |
| let mut w = ~create(); | |
| function(w); | |
| } | |
| /* | |
| bin.rs:25:19: 25:28 error: mismatched types: expected `*mut c_struct` but found `*c_struct` (values differ in mutability) | |
| bin.rs:25 c_function(a.payload); | |
| ^~~~~~~~~ | |
| error: aborting due to previous error | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment