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 avoid clone when destructuring tuple?
Return value from match to Err(e)
Get actual path symlink is pointing to
How do I create a class with multiple instantiation options
Struct must outlive member reference
How to solve this lifetime-related error?
How to pass a mutable function parameter as argument to another function?
How to compile and run an optimized Rust program with overflow checking enabled
How do I specialize a trait function?
How to store recursive ref inside of a struct
Value does not live long enough with explicit lifetime, but does live long enough when omitted
Borrowing Option::and_then
Redirect panics to a specified buffer
How can I have a container where the items have access to the container?
Borrow inner data from struct in a wrapper function
Allowing both static variables and boxes as a function argument?

Categories

HOME
extjs
libgdx
mod-rewrite
yaml
vagrant
swi-prolog
transactions
hdfs
out-of-memory
apk
jersey-2.0
malware
qooxdoo
tibco
linker
clone
graphql-js
sharepoint-online
fbloginview
jquery-select2-4
powermock
supervisord
google-cloud-logging
closures
l20n
parceler
adminlte
android-custom-view
kaggle
sipp
tortoisehg
dnsmasq
fusion
substance
argv
rust-cargo
quickcheck
jfxtras
uivisualeffectview
android-alarms
unification
ng-repeat
best-buy-api
task-parallel-library
microkernel
system-on-chip
grails3.2.0
minikube
supertest
scala-breeze
brightscript
mongodb-aggregation
connect-direct
dynamics-crm-4
sidewaffle
prefetch
bpms
thread-exceptions
wininet
meld
mathnet
vaadin4spring
swiffy
taco
myfaces
helm
in-app-billing
place
roxygen2
sunos
n-tier-architecture
ildasm
utf8-decode
global-scope
zend-mail
inputbox
quantify
nidaqmx
senchatouch-2.4
redpitaya
nodeload
sensormanager
jquery-cycle
smartfox
lynx
gitx
stretch
msinfo32
system-information
java.lang.class
monocross
fitch-proofs
quartz-core
radscheduler
directshow.net
sqlsitemapprovider
rakudo
rendering-engine

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile