On 14/04/14 19:04, Flaper87 wrote:



2014-04-13 22:22 GMT+02:00 György Andrasek <[email protected] <mailto:[email protected]>>:

    You could make a container struct:

        struct Dev {
            ptr: *mut InternalDev
        }

    and then impl your methods on that.


I'd recommend using `Unsafe` which was added to wrap types T and indicate an *unsafe interior*. It exposes a `get` method that returns a `*mut` pointer to the wrapped data.

Here's the link to the Unsafe docstring (which also contains an example): https://github.com/mozilla/rust/blob/master/src/libstd/ty.rs#L16


Flavio


--
Flavio (@flaper87) Percoco
http://www.flaper87.com
http://github.com/FlaPer87


_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev


I'm not sure that Unsafe is particularly useful here, since the goal is to avoid unsafety by providing a sensible wrapper around the raw pointer (since some methods are "known" to be safe). Also, the rendered docs are a better place to which to link: http://static.rust-lang.org/doc/master/std/ty/struct.Unsafe.html


Huon
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to