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

How to create a Quickcheck Arbitrary of a struct containing a reference?
Posting form data with nickel.rs works the first time, returns 404 subsequent times
How do I hold a collection of one struct in another where lifetimes are not predictable?
Why does Rust have both call by value and call by reference?
Error: borrowed value is only… reference must be valid for
In Rust how do you pass a function as a parameter?
Obtaining rustdoc for particular function or trait
Rust slice ownership outlives its scope
What's purpose of ErrorKind::__Nonexhaustive?
A set type that preserves insertion order
Rust closure type mismatches of seemingly opposing natures
How can I build multiple binaries with Cargo?
borrowed value does not live long enough in this case ( Vec<&Fn(i32) -> i32> )
Mutability issue with self and collections in Rust
Recommended way to wrap C lib initialization/destruction routine
Return either a borrowed or owned type in Rust

Categories

HOME
verification
freeradius
jms
scroll
code-formatting
theano
material-components
hyperledger
dji-sdk
kurento
mailing-list
yahoo
cqrs
ex
stimulsoft
spring-jpa
vmware-workstation
web-deployment
mixpanel
fosuserbundle
boomi
salt-cloud
renderscript
nullreferenceexception
jest
hdl
opentext
jstree
uri
annotation-processing
php-5.3
bonita
sfml
javax.persistence
premake
image-optimization
polyml
char-pointer
textmate2
praat
type-inference
ipp-protocol
tinyioc
password-hash
mongodb-aggregation
alertify
dynamics-crm-4
prefetch
gapi
e
jsonix
svnserve
django-testing
android-sdcard
gnucash
noclassdeffounderror
simian
ioexception
enunciate
openshift-cartridge
auto-generate
canopy
apple
replicaset
gflags
camus
mathematical-expressions
incron
mojo
jolie
uno
microsoft-expression-web
visual-c++-2012
miglayout
accountmanager
jms-serializer
spring-security-acl
application-blocks
indesign-server
jquery-lazyload
wiktionary
firefly-mv
database-deadlocks
simile
ognl
nsconnection
.net-services
wmd-editor
code-camp

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