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

Cannot borrow variable when borrower scope ends
Rust RAM limited LRU cache? [closed]
How to determine messages in .rs files generated from rust-protobuf included by include! macro
Replacing a borrowed Arc<RwLock>
How to concatenate a literal string with a const string?
Replacing a borrowed variable
Type hinting on Rust function calls
Nesting an iterator's loops
Do literal integral values have a specific type in Rust?
What value does the variable in the following code snippet have?
How do you import macros in submodules in Rust?
Local let like in caml
E0309: Constraining a generic type parameter's lifetime
Are nested matches a bad practice in idiomatic Rust?
Extern crate inside main method; module::Type vs main::module::Type
Iterating over named regex groups in Rust

Categories

HOME
orientdb
kendo-dropdown
foaf
activemq
dafny
out-of-memory
consul
lvm
apache-kafka-connect
navigation
stored-procedures
ag-grid
firebase-dynamic-links
static-analysis
yeoman-generator-angular
cname
temperature
cloudsim
bazaar
android-custom-view
angular2-highcharts
conda
websphere-portal
plyr
window-managers
jackrabbit-oak
basex
annotation-processing
laravel-4.2
boolean-logic
amazon-iam
premake
argv
rust-cargo
microsoft-certifications
listjs
mongoengine
directfb
assertions
twilio-php
xll
gitolite
best-buy-api
task-parallel-library
microkernel
windows-store
viewcontroller
dagger
1wire
httphandler
common-table-expression
spongycastle
realstudio
cloudwatch
gestures
swiperefreshlayout
msxml
boost-compute
bigdecimal
tablespace
livecycle
mathml
android-sdcard
ajaxmin
uibinder
frame-grab
openmrs
variable-length-array
canopy
wso2ml
replicaset
explain
ocmockito
mathematical-expressions
incron
maven-shade-plugin
directorysearcher
sunos
relationships
hyperloglog
sql-function
xmi
grails-2.3
acitree
notifyjs
lru
jacob
xmlwriter
dojo-1.9
telerik-ajax
first-class
cakeyframeanimation
haiku
server-variables
vows
qt-mobility
fork-join
kohana-auth
digiflow
servlet-container
pyjamas
cleartype
accumulator
jboss-mdb
activex-exe

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