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

Importing non-root module from multiple non-root binaries
Could this scoped thread code be changed to use `FnOnce()` instead of `Box<FnOnce()>`?
Unable to create hyper::Client because the compiler cannot infer enough type information
How to handle errors in mio?
Why is it discouraged to accept a reference to a String (&String) or Vec (&Vec) as a function argument?
Is `iter().map().sum()` as fast as `iter().fold()`?
How to dump a complete list of compiler attributes in Rust?
Deriving a trait results in unexpected compiler error, but the manual implementation works
Сannot move out of borrowed content for a struct
rustc_serialize::Json value borrowed in a while loop does not live enough
Is there a more beautiful way to convert a character literal to its corresponding escape character?
How to quiet a warning for a single statement in Rust?
Make object expire given a state change in Rust
Is there a way to determine the offsets of each of the trait methods in the VTable?
Is it possible to return something or nothing?
How do I read multiple integers from a single line of stdin?

Categories

HOME
powerbi
gaming
windows-8.1
yii
seedstack
applescript
softlayer
activemq
braintree
ios-simulator
cryptography
greasemonkey
implicit-conversion
turbojpeg
scheduler
gtk
hystrix
fasm
parsley.js
graphdb
game-maker
chromecast
mailmerge
fullcalendar-scheduler
cuba-platform
dma
texas-instruments
scala-ide
salt-cloud
codefluent
spam
pfobject
social-tables
gitkraken
weex
sipp
quartz.net
tracing
plyr
python-appium
uri
ruby-daemons
jackrabbit-oak
history.js
react-bootstrap-table
iwebbrowser2
amazon-cloudtrail
sparkle
materialize
substance
steam-web-api
memory-fences
delayed-job
cloudera-manager
devtools
custom-keyboard
gnu-classpath
polyml
xvfb
installanywhere
microsoft-ui-automation
gitolite
swfupload
opal-framework
pyttsx
optionaldataexception
swift2.3
roracle
ol3-google-maps
uiautomatorviewer
openstack-glance
entropy
webvtt
algebra
alertify
degrees
dymola
kendo-treeview
haraka
elastic4s
controllers
cdo.message
groovyfx
meld
jeditable
persistent-object-store
preferenceactivity
ioexception
lovefield
gitlab-omnibus
enaml
espresso
sequence-sql
ampersand
erlog
tree-structure
subview
ssmtp
uno
adhoc-polymorphism
symja
inequality
otl
senchatouch-2.4
rails-api
profiles
cloo
objective-c-runtime
semicolon
system-requirements
multiscaleimage
image-formats
sql-parametrized-query
jmenu
firephp
processors
.net-client-profile
datagridcolumn
gui-designer
synthesizer

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