rust
How safe is this behavior of GTK-rs Builder::get_object?
In The Rust Programming Language, it says something like: Move semantics There’s some more subtlety here, though: Rust ensures that there is exactly one binding to any given resource. For example, if we have a vector, we can assign it to another binding: But I found that I can do this using gtk-rs: let label1: gtk::Label = builder.get_object("label1").unwrap(); let label1_test: gtk::Label = builder.get_object("label1").unwrap(); Both now point to the same resource "or something happens to me." Builder::get_object is defined as: pub fn get_object<T: IsA<Object>>(&self, name: &str) -> Option<T> { unsafe { Option::<Object>::from_glib_none( ffi::gtk_builder_get_object(self.to_glib_none().0, name.to_glib_none().0)) .and_then(|obj| obj.downcast().ok()) } } Although this is not really something from Rust directly, just from gtk-rs, I was wondering if I am right and how sure is this. Maybe it could use Rc?
Related Links
How to create an `IpAddr` without knowing the specific IP version?
Can Cargo download and build dependencies without also building the application?
Using the Rust compiler to prevent forgetting to call a method
Problems with mutability in a closure
Lifetime differences between references to zero sized types
Assignment from Rust match statement
Easily convert third party Errors to String
Why does Cargo create multiple directories for the same registry?
Struct with a generic trait which is also a generic trait
Rustup vs Cargo binaries
How to redirect child process output to stderr?
Why does Rust not permit type inference for local constants?
How do I find the function pointers for tests from the LLVM IR code of a Rust program?
How to check in Rust if architecture is 32 or 64 bit?
How can I succinctly combine many `Result`s of different types?
Why is the produced assembly not equivalent between returning by reference and copy when inlined?