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

Convert a char to upper case
Parsing HTML page content in a stream with hyper and html5ever
Using enum in a struct results in “unresolved name” error
type mismatch error while reading stdin lines
Is it possible to build an iterator that yields a reference to an object that it modifies in next()?
Way to specify a static slice of variable length
Clonable iterator trait object
How to make Rust BTreeMap::get return a String?
Websocket client message payload “does not live long enough”
How to express that some returned types implement a trait?
“trait core::ops::Fn<(Request, Response)> is not implemented” for a closure when passing a connection pool to a Hyper handler
Can I inherit structs in Rust? [duplicate]
std::ops::Add or core::ops::Add?
How to write a safe wrap for HashMap with default value
Vec::iter() converts to borrow of Option
Why does the address of a variable change when I add multiple '&'?

Categories

HOME
cucumber
dotnetnuke
subdomain
stacktrace.js
jersey-2.0
elisp
share
tup
mutation-testing
fasm
grocery-crud
powermock
texas-instruments
pygobject
boomi
codefluent
hdl
multi-upload
fluent-migrator
substring
vuforia
fstar
android-cardview
ninject
bitbake
infopath2010
python-2.x
overwrite
image-optimization
wdk
pdfnet
jade4j
cartopy
sspi
reset
task-parallel-library
hdiv
dagger
haar-classifier
httphandler
return-type
icecast
solr-query-syntax
webvtt
word-2007
email-forwarding
kendo-editor
zend-server
degrees
cognos-tm1
nrf51
oid
jsonix
dmarc
android-4.2-jelly-bean
jtag
eclemma
odp.net-managed
rails-engines
jemdoc
mercurial-extension
mnesia
gravatar
grinder
odesk
cryptojs
chicagoboss
dsa
highest
darwin
unidata
flow-js
image-rotation
angular-ui-select
reference-counting
sqlbindparameter
pageviews
map
armv6
cloo
particle-swarm
facebook-game-groups
virtual-channel
jacob
microformats
handshake
playorm
trialware
prototypal-inheritance
sigar
git-log
active-record-query
aggregator
tso
activex-exe

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App