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 create an `IpAddr` without knowing the specific IP version?
Can Cargo download and build dependencies without also building the application?
Using the Rust compiler to prevent forgetting to call a method
Problems with mutability in a closure
Lifetime differences between references to zero sized types
Assignment from Rust match statement
Easily convert third party Errors to String
Why does Cargo create multiple directories for the same registry?
Struct with a generic trait which is also a generic trait
Rustup vs Cargo binaries
How to redirect child process output to stderr?
Why does Rust not permit type inference for local constants?
How do I find the function pointers for tests from the LLVM IR code of a Rust program?
How to check in Rust if architecture is 32 or 64 bit?
How can I succinctly combine many `Result`s of different types?
Why is the produced assembly not equivalent between returning by reference and copy when inlined?

Categories

HOME
amazon-web-services
entity-framework
protocol-buffers
shinyapps
openxml
yii
softlayer
add-on
dafny
slider
drag-and-drop
visualforce
telegraf
scheduler
fasm
alljoyn
erd
pm2
xbap
freertos
bnf
office-ui-fabric
azure-machine-learning
pst
coreldraw
sharedpreferences
gollum-wiki
uilocalnotification
bobo-browse.net
laravel-4.2
autodesk-model-derivative
memory-fences
wampsharp
microsoft-certifications
shapeless
redgate
xvfb
ms-dos
google-now
reset
jacoco-maven-plugin
git-tfs
jshint
wysihtml5
dredd
renderman
extjs4.1
android-sharing
webvtt
gtk#
nivo-slider
cognos-tm1
rational-performance-test
deviare
decoder
svnserve
nvda
dojo-build
qpixmap
highlighting
node-glob
django-redis
bayesglm
miniconda
linuxbrew
perceptron
auto-generate
enaml
netdatacontractserializer
alwayson
console.log
deque
maven-shade-plugin
google-hangouts
lifetime
device-admin
adwords-apiv201402
lmax
principalcontext
meteorite
saga
application-server
blobstorage
chefspec
itunes-sdk
red-system
simplecov
jdom
expression-web
representation
libxslt
pyjamas
eaccelerator
fgetc
facebook-fbml
spring-modules
suggestbox

Resources

Encrypt Message