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

What's the easiest way to read several ints from stdin if it's ok to fail?
Can I use the Rust lexer or parser to retrieve a list of functions within a Rust file?
Assign value from match statement
Why does unsafe code compile, but similar code that pushes to a vector complains that a reference doesn't live long enough?
How can I find a subsequence in a &[u8] slice?
Safe way to push the local value into a static mut
Is there a way to detect the compiler version from within a Rust program?
Modifying a Mutex<Option<>>
How can I implement Ord when the comparison depends on data not part of the compared items?
Rust Documentation Test unresolved name [duplicate]
How to convert a boxed array into a Vec in Rust
Rust executable linking to a system library works, but a library has unresolved references
mismatches between str and string
How to share mutable state for a Hyper handler?
Error: closure requires unique access to `self` but `self` is already borrowed
How can the state be shared between the returned result and the next iteration when using the scan iterator?

Categories

HOME
amazon-web-services
visual-studio
nam
matrix
keyboard
seedstack
exchange-server
workflow
hdfs
openlayers-3
google-play-services
web2py
azure-data-lake
phpseclib
cocotb
gtk
yahoo
lc3
scrape
cqrs
slide
clish
squirrel-sql
async-await
exe
jitsi
batch-rename
pubxml
pyspark-sql
ibm-connections
snap-framework
eclipse-gmf
django-smart-selects
widestring
pyttsx
yoast
web-inspector
code-push
aws-kinesis-firehose
scala-breeze
uiautomatorviewer
sonatype
pen
1010
instafeedjs
oracle-fusion-apps
cefpython
xcode6.4
callouts
android-sdcard
adjacency-list
urbit
diawi
lovefield
phpquery
godeps
android-mapview
canopy
gitlab-omnibus
apple
supersocket.net
green-threads
dynamics-ax-2012-r2
algebraixlib
artisan
quercus
maven-shade-plugin
sunos
rebar
iodocs
igor
quantify
nidaqmx
forceclose
nodeload
windows-taskbar
autonumber
discovery
sql-view
hints
arel
simplecov
email-verification
sfinae
nsfont
asio
fragment-identifier
grails-validation
qcar-sdk
j2mepolish
processors
community-server

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile