rust


Using managed and owned pointers together


I'd like to understand the meaning of the following code snippet from "12 Dereferencing pointers" of Rust tutorial:
let point = &#~Point { x: 10f, y: 20f };
println(fmt!("%f", point.x));
Especially, what does #~ mean?
It is simply an application of multiple pointer-taking operators. You can put braces to see it clearer (though I don't know whether it is valid Rust code):
&(#(~Point { x: 10f, y: 20f }))
This is really a borrowed pointer to a managed box which contains unique pointer to a struct.
Such thing, of course, is useless in real code but it demonstrates dereferencing concept.
The expression is a reference to a managed pointer to an owned pointer to a Point.
The sentence above gives a good hint:
You can write an expression that dereferences any number of pointers automatically. For example, if you feel inclined, you could write something silly like
It's simply to demonstrate that you can have a pointer to a pointer to something. The code is certainly silly in that this snippet doesn't make good use of the concept, it's simply to show off the syntax.
For more on pointers to pointers, you might enjoy this question: How do pointer to pointers work in C?

Related Links

rust - std::string::String as a byte string (i.e. b“foo” or deprecated bytes!(“foo”))
In Rust, how can I fix the error “the trait `core::kinds::Sized` is not implemented for the type `Object+'a`”
Boxed value does not live long enough
inspect rust traits at runtime
Enums with constructions in Rust
How can I unify the lifetimes between a struct and a trait?
PNaCl support for Rust
Store value in struct through trait
Rust not running helloworld example
Why does #[derive(Show)] not work anymore?
How do lifetime bounds on structs work in Rust?
Rust - how to retrieve a user-defined type from for loop
rust: error: macro undefined: 'fail!'
Match String Tuple in Rust
How can I make a structure with internal references?
Iterating over the contents of an Option, or over a specific value

Categories

HOME
hpoo
oracle
macos-sierra
generics
barcode-scanner
foaf
operating-system
subdomain
ios-simulator
tfs2015
supercollider
sentry
ag-grid
swarm
log4j2
grocery-crud
feature-extraction
android-5.1.1-lollipop
uima
fosuserbundle
susy-sass
salt-cloud
scheduled-tasks
deepfreeze
mime-types
react-dnd
jpa-2.1
fusetools
android-service
uilocalnotification
adapter
amazon-iam
intune
series
pdfminer
uivisualeffectview
telephonymanager
hidden-markov-models
tidal-scheduler
best-buy-api
right-click
grails-spring-security
jacoco-maven-plugin
get-event-store
viewcontroller
optionaldataexception
vungle-ads
dbcc
asihttprequest
tinyioc
brightscript
amazon-elastic-beanstalk
webvtt
word-2007
network-protocols
rcharts
mpmovieplayercontroller
email-injection
haraka
elastic4s
multi-touch
openquery
meld
vaadin4spring
python-cffi
nastran
highest
360-degrees
swagger-maven-plugin
sequence-sql
flow-js
signed
sunos
dc
producer
visual-studio-6
distributed-r
usb-flash-drive
node.js-stream
delphi-xe4
ofstream
jquery-cycle
cmath
smartfox
ip-geolocation
towers-of-hanoi
nsmutablestring
jzmq
type-safety
drawimage
database-deadlocks
startupscript
tablet-pc
mongrel2
mongrel
html-components
google-translator-toolkit
main-method
synthesizer
parentid

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