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 would you create a constructor for a struct containing a closure?
How using Rust do I assign the value being matched as the result?
How Do I pass object “std::rand::task_rng()” to a function in Rust?
Using Rust, is there a faster/shorter way to initialize variables in a struct?
How does Rust handle rounding in conversion of f64 to i64?
Using Rust and the match statement how can I assign a TcpListener?
How can I detect an error rather than have this Rust program abort?
Why does i32 perform better than i64 using Rust on Win8-64?
Error with Rust: cannot call a method whose type contains a self-type through an object
Comparing string with static string
How do a pass a database variable to a function in Rust?
What happens in Rust using “match” if nothing matches?
The English alphabet as a vector of characters in Rust
How do I convert a Vector of bytes (u8) to a string
Why using Rust does passing a mutable struct to a function result in immutable fields?
Using managed and owned pointers together

Categories

HOME
qt
blast
openxml
angular-ui-grid
yahoo-weather-api
lvm
tibco
ipv6
repair
minecraft
vertica
parceler
el
multi-upload
amazon-sns
managed-c++
plyr
uri
gravity-forms-plugin
basex
miniprofiler
tsung
sales
plantuml
mongoengine
cmis
bootstrap-sass
transform
gitolite
sspi
oauth2
right-click
klee
get-event-store
oauth2-playground
permission-denied
viewmodel
sonarqube5.2
ssi
pen
http-basic-authentication
front-camera
mathjs
livereload
visual-studio-monaco
cdo.message
apache-pig-grunt
urbit
in-app-billing
mixins
alwayson
kefir.js
unidata
abstract-factory
tree-structure
signed
google-hangouts
datagridcomboboxcolumn
image-rotation
gpu-programming
property-injection
spring-social-linkedin
code39
compiler-flags
eclim
vlab
infinite
ax
apportable
cmath
significant-digits
xmlwriter
icenium
tridion-2011
getproperty
sfinae
coordinate
navigationcontroller
dynamic-c
snackjs
nsrangeexception
css-friendly
qcar-sdk
dip
chunking
ccnet-config
external-sorting
tacit-programming
gtktextview
downcasting
prism-2
remote-working
downloadfile

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App