Rust - Types and Function

taeyang koh·2024년 11월 26일

Some Rust basic things are below:
how to write comments
Types
function

How to write comments

  • comments
    lines with two backslashes
    or backslash and star
  • outputs
    println!("Hello, World!);
    the exclamation mark is a symbol to denote a Rust macro
    a macro is a way of writing code that writes other code which is a.k.a. metaprogramming
    print!("Good evening");
    it does not move over to the next line
    \n: move to the next line
    to print quotes, use \
    you can use numbers to print with placeholders
    you can use variables, operators
    code is here
fn main() {
    // This is how we write comment
    
    /* and this is another 
    
    way to write comment */
    
    println!("Hello, World!");
    print!("Good evening ");
    
    println!("let's move to the next line\nthis is new line");
    
    println!("print quote \' and double quote \"");
    
    println!("\ndoing {2} for {1} years and i {0} it", "love", 2, "learning");
    
    println!("{language} is a system programming laguage", language = "Rust");
    
    println!{"The summation of 25 + 10 = {}", 25 + 10};
    
}

Types: Scalar, Compound

Scalar Data Types: integers, floats, booleans, char

println!("The maximum number in i8 is = {}", std::i8::MAX);

Compound Data Types: Strings, Tuples, Arrays, Vectors

Strings - &str, string

profile
Passionate about crafting optimized systems that contribute to a brighter, better future

0개의 댓글