rust


Does if-let with a pair short-circuit?


Suppose f() and g() return Option<T>.
if let (Some(x), Some(y)) = (f(), g()) {
h();
}
If f() returns None, will g() be evaluated? Is evaluation guaranteed or prohibited by the spec?
It does not shortcut. To pattern-match against the pair, the pair must be fully constructed, which means both f and g have been called. There is no lazy evaluation where the pattern match could happen before the values are calculated.
(By the way, it's easy to try out, and the Rust compiler pretty much is the spec right now.)

Related Links

How to make a simple futures::sync::mpsc::channel example work?
Is there a way to let Rust infer the correct type for an associated type?
How to encapsulate resources and their references in one struct in Rust? [duplicate]
How would one return a function from a function in Rust?
Lifetime on trait returning iterator
Mutable borrow of self doesn't change to immutable
How do I specify the linker path in Rust?
Are raw pointers to temporaries ok in Rust?
How to destructure tuple struct with reference
Unable to use std::process::Command to SSH - No such file or directory
“borrowed value does not live long enough” error in trie insertion
How to check for EOF in read_line in Rust 1.12?
Can I create an owned pointer to a stack object
How do I abort a Rust process?
Is it possible to disable Rust's lifetime elision?
How to implement Index over a wrapped HashMap?

Categories

HOME
svn
keyboard
dafny
celery
google-play-services
mosquitto
firebase-database
roku
google-tasks-api
android-contacts
maven-plugin
adminlte
amazon-mws
unity-container
mime-types
device
pdf.js
react-dnd
introspection
cellular-network
running-object-table
miniprofiler
docx4j
locks
steam-web-api
appcode
cups
jade4j
nanogallery
ms-dos
llvm-ir
viewcontroller
access-denied
cloudwatch
aws-kinesis-firehose
icecast
freshdesk
winmerge
nslayoutconstraint
nivo-slider
1010
alertify
mpmovieplayercontroller
http4s
ogg
data-management
visual-studio-monaco
django-testing
xcode8-beta4
meld
processor
textblock
django-redis
wif4.5
flask-security
ui4j
boost-proto
cryptojs
arbre
apache-commons-digester
fuseesb
maven-shade-plugin
senchatouch-2.4
application-server
san
coalesce
hints
indesign-server
delphi-xe4
oscilloscope
semicolon
background-thread
dojo-1.9
sfinae
msinfo32
uipangesturerecognizer
liveconnect
exponent
wiktionary
will-paginate
winsxs
rtd
bll
qcar-sdk
ios-4.2
fxruby
ntruencrypt
downloadfile
jvm-bytecode

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