Search
 
SCRIPT & CODE EXAMPLE
 

RUST

rust enum to string

enum Foo {
    Bar = 0x00,
    Baz = 0x01,
    Qux = 0x02,
    // ...
    Quux = 0xFF,
}

impl fmt::Display for Foo {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "{:?}", self)
        // or, alternatively:
        // fmt::Debug::fmt(self, f)
    }
}

let s: String = Foo::Quux.to_string();
Comment

PREVIOUS NEXT
Code Example
Rust :: rust in a string, replace multiple spaces with single space 
Rust :: rust convert a string (with decimals) to a floating point number. 
Rust :: rust String to &str 
Rust :: sum all elements of array rust 
Rust :: rust•armanriazi•thread•unsafe 
Rust :: split rust 
Rust :: how to make map in rust language 
Rust :: create a new rust project folder with cargo 
Rust :: string and str to string rust 
Rust :: rust string interpolation 
Rust :: packet sniffing with rust 
Rust :: rust using regex in if statement 
Rust :: rust comments 
Rust :: rust return the result with trait exit status 
Rust :: rust•armanriazi•borrowchecker•ownership 
Rust :: char is digit rust 
Rust :: decimal in rust 
Rust :: convert i32 to usize rust 
Lua :: Get number of values in a table lua 
Lua :: luau kill brick script 
Lua :: lua last item in table 
Lua :: roblox studio mouse 
Lua :: roblox tweenservice 
Lua :: roblox check if in private server 
Lua :: lua f animation 
Lua :: rhyme api 
Lua :: lua to integer 
Lua :: check if play is in group 
Matlab :: matlab get real and imaginary part 
Matlab :: matlab symbolic integration 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =