Search
 
SCRIPT & CODE EXAMPLE
 

RUST

Vector with multiple types in rust

enum Thing {
    Op(Operator),
    Number(i32),
}

fn main() {
    let mut output: Vec<Thing> = Vec::new();
    let a = 2;
    let b = Operator::Add;
    let c = 3;
    output.push(Thing::Number(a));
    output.push(Thing::Op(b));
    output.push(Thing::Number(c));
}
Comment

PREVIOUS NEXT
Code Example
Rust :: find prime numbers with the sieve of Eratosthenes 
Rust :: rust•armanriazi•let•const 
Rust :: rust init vector with range 
Rust :: update a value in hashmap in rust 
Rust :: macro_rules! 
Rust :: execution duration 
Rust :: reverse a string with runes 
Rust :: rust range step 
Lua :: print table lua 
Lua :: lua dump table 
Lua :: sleep function lua 
Lua :: luau kill brick script 
Lua :: roblox how to tween part color 
Lua :: lua array is empty 
Lua :: input in lua 
Lua :: roblox what is humanoid 
Lua :: glua varargs 
Lua :: what is lua used for 
Lua :: to the power of in lua 
Lua :: how to make everyone on team see name roblox 
Lua :: while loop lua 
Lua :: pico8 draw sprite 
Lua :: roblox manually stop command bar loops 
Matlab :: matlab how to set figure size so you can see plot 
Matlab :: log matlab 
Matlab :: geom_density_2d 
Basic :: Detailview with form mixing 
Elixir :: elixir check type data 
Elixir :: split list in elixir 
Scala :: scala match 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =