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

Rust: downcasting and Box<Any>
Do I have to 'use' a trait in order to call methods defined in that trait?
lifetime of Option.map's function argument
Using T from Option<T> as function parameter in Rust
References and lifetimes
Returning object containing references in Rust
Exhaustive integer matching
Index and IndexMut implementations to return borrowed vectors
Is it possible to have a Closure/Function as a member of a struct?
Why “explicit lifetime bound required” for Box<T> in struct?
Do I need any of the *variantType markers?
Cargo: invalid character `.` in crate name
Is it possible to split an impl into different modules?
Problems building rust-http in rust-openssl
How to clear the Cargo cache?
Where to put static Library?

Categories

HOME
nam
flask
list
typelite
shinyapps
facebook-messenger
xcode8.1
long-integer
bots
concurrency
windows-10
risk-management
adobe
initialization
ios-simulator
websocket
semantic-web
portable-class-library
capistrano
stored-procedures
mithril.js
lc3
scrape
graphdb
buffer
responsivevoice
synthesis
temperature
hidden
tfsbuild
azure-machine-learning
android-permissions
pst
altium-designer
channel
ava
pdf.js
tortoisemerge
network-analysis
sendmessage
sfml
audit
monitor
credit-card
winsock
infopath2010
windows2012
gsp
autoencoder
dreamfactory
subclassing
python-sounddevice
uipickerview
oauth2-playground
flipkart
fluid-mac-app-engine
notesview
asihttprequest
doctrine-extensions
sonarqube5.2
beeline
phppgadmin
freshdesk
emf-compare
perl-data-structures
spring-mongo
xcode8-beta4
fiber
swiffy
vimperator
okta-api
univocity
flush
screen-orientation
pythonxy
hmisc
espresso
android-handler
mobilefirst-server
html-escape-characters
htmltidy
operands
dos2unix
visual-studio-6
category-theory
treeline
accessory
csslint
wso2bam
lru
ax
jquery-cycle
examine
dojo-1.9
audiotoolbox
pageheap
flymake
quartz-core
multidrop-bus
litespeed
motodev-studio
grails-validation
nsconnection
explicit
tessellation
resharper-5.0
rational-unified-process
gtktextview
html-generation
jvm-bytecode
webclient.uploaddata

Resources

Encrypt Message