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

Iterator over elements around specific index in Vec<Vec<Object>>
Return Traits from function
Lifetime for a From trait implementation
Object safety and trait inheritance [duplicate]
How do I specify that a function takes a HashMap?
Cannot implement quickchecks Arbitrary for my own type - “source trait is private”
Returning the T borrowed from RefCell<T>
Trait implementing Sized
Are unique object ids tracked and can we print them?
How can I specify lifetimes in associated types?
What's the best way to mutate a nested enum?
Mutating the same data in multiple 'static closures
Return value is a “unresolved name”
Implementing struct that has lifetimes
Where does the Rust 1.0 Mac OS X pkg installer install to?
Want to add to HashMap using pattern match, get borrow mutable more than once at a time

Categories

HOME
webview
livecode
barcode-scanner
systemd
devexpress
embedded-resource
repair
position
mailing-list
clish
cuba-platform
supervisord
coroutine
scheduled-tasks
home
bluemix-mobile-services
gitkraken
pst
intel
vuforia
password-generator
high-availability
multi-dimensional-scaling
xdebug
msdeploy
sfml
netbios
nsmutablearray
cucumber-junit
overwrite
directfb
bean-validation
landscape
mv
telephonymanager
mars-simulator
access-denied
apache-toree
destroy
music21
karabiner
winston
gmaps.js
ltrace
sidewaffle
gawk
nclam
ndk-build
data-management
highlighting
jeasyui
gridbaglayout
psd
vim-plugin
servicestack-bsd
cryptojs
roxygen2
ipod
kotlin-android-extensions
prism-4
google-hangouts
device-admin
visual-studio-6
ecos
treeline
webautomation
pageviews
webaii
mod-perl
hyphen
ggts
notifyjs
axacropdf
android-authenticator
word-frequency
kobold2d
fbml
upshot
ninject-interception
odac
fgetc
getimagesize
google-translator-toolkit
sqlsitemapprovider

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App