Search
 
SCRIPT & CODE EXAMPLE
 

RUST

armanriazi•rust•binding•match

//https://blog.rust-lang.org/2018/05/10/Rust-1.26.html#nicer-match-bindings
        // `self` has type `&List`, and `*self` has type `List`, matching on a
        // concrete type `T` is preferred over a match on a reference `&T`
        // after Rust 2018 you can use self here and tail (with no ref) below as well,
        // rust will infer &s and ref tail. 
//the compiler automatically references the Some, and since we're borrowing, name is bound as ref name automatically as well. If we were mutating:

fn hello(arg: &mut Option<String>) {
    match arg {
        Some(name) => name.push_str(", world"),
        None => (),
    }
}
//the compiler will automatically borrow by mutable reference, and name will be bound as ref mut too.
Comment

PREVIOUS NEXT
Code Example
Rust :: macro_rules! 
Rust :: rust•armanriazi•trait•PartialEq 
Rust :: armanriazi•rust•error•E0277•the trait bound `` is not satisfied 
Rust :: armanriazi•rust•function•vs•closure 
Rust :: armanriazi•rust•error•already borrowed: BorrowMutError 
Rust :: rust range step 
Lua :: kerbal space program 2 
Lua :: luau make a rainbow part 
Lua :: how to choose a random item from a table lua 
Lua :: luau make region3 
Lua :: roblox difference between index and newindex 
Lua :: roblox tween 
Lua :: lua globals 
Lua :: roblox studio mouse 
Lua :: lua hello world function 
Lua :: while true do lua 
Lua :: What is transparency in roblox 
Lua :: countif excel 
Lua :: roblox player chatter event 
Lua :: lua unpack 5.4 
Lua :: how do i use the enums module lua assist 
Lua :: C++ 914 card 
Lua :: roblox lua 
Matlab :: octave mark axis labels 
Matlab :: alternative from two vectors matlab 
Basic :: bash catch ctrl-c in a script 
Basic :: add combobox in datagridview vb.net 
Elixir :: phoenix query get first record 
Scala :: quantification scalaire 
Scala :: if scala 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =