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

Cannot ignore failures to compile example code in documentation
Borrow errors for multiple borrows
no method named `flush` found for type `std::io::Stdout` in the current scope
Parse a string containing a Unicode number into the corresponding Unicode character?
Why do I get an error about non-exhaustive patterns?
How do I concatenate two slices in Rust?
How to return Any from a function?
How to call functions that aren't inside a module from the test module?
How to get the offset of a struct member in Rust? (offsetof) [duplicate]
Preventing value from dropping inside generic match [duplicate]
Compare a borrowed integer to a literal integer
Why can you only specify type restrictions with traits?
Why is std::rc::Rc<> not Copy?
Why does Rust store i64s captured by a closure as i64*s in the LLVM IR closure environment?
What is the most efficient way to clone a fixed-sized array?
Can't impl a type trait requiring Debug for a type containing PhantomData [duplicate]

Categories

HOME
qt
memory
mc
typelite
seedstack
d3.js
applescript
dry
visual-studio-2010
android-emulator
position
ag-grid
telegraf
kurento
gtk
match
createjs
freertos
sql-injection
asp.net-core-1.0
android-5.1.1-lollipop
maven-plugin
susy-sass
http-authentication
cpu-usage
parceler
mime-types
introspection
android-cardview
dnsmasq
progid
delayed-job
gnu-classpath
spring-rabbitmq
restful-architecture
express-session
xll
windows-store
fiware-wirecloud
haar-classifier
web-inspector
apache-toree
spongycastle
realstudio
directwrite
entropy
skip-lists
wildfly-9
s-function
visual-studio-monaco
maven-release-plugin
ajaxmin
swiffy
textblock
webgrind
miniconda
perceptron
openshift-cartridge
libz
mathematical-expressions
tidyr
nsmutabledata
nhibernate-criteria
google-hangouts
cout
category-theory
mfmessagecomposeview
nachos
tabletools
cpu-time
mod-perl
lync-2010
django-sites
cloo
spring-security-acl
sensormanager
visual-c++-2005
iirf
apportable
pacman
statechart
eager-loading
2d-vector
xmlwriter
office-app
email-verification
ip-geolocation
daap
struts2-json-plugin
image-formats
prefuse
trialware
filelock
jmenu
channelfactory
android-2.1-eclair
resharper-5.1
outlook-2007-addin
eventaggregator
main-method
jboss-mdb
bindable-linq

Resources

Encrypt Message