Search
 
SCRIPT & CODE EXAMPLE
 

RUST

rust struct

struct Data {
	randomInfo: String
}

let mut Data {
	randomInfo: "This is a structure"
}

/* 
 The mut keyword defines whether or not you can mutate (change)
 the variable (in this case a structure), so if you don't want tp be able to 
 change the data then don't use the mut keyword. Like so:
*/

let Data {
	randomInfo: "This is a structure"
}
Comment

struct in rust

// as example a for a person
struct Person {
    pub name    : String,   // public
    age     : u8,           // private
    // here are all the attributes and there types
}
// impl contains all functions and methods that will be implemented to your struct
impl Person {
    // a function from the class itself
    fn new(name:String, age:u8) -> Self {
      	// crate an instace of the class
        Person {
            name    : name,
            age     : age
        }
    }
    // a method from an object of this class
    fn get_age(self) -> u8 {
        // `self` is the object itself and the same like `this` in java
        self.age
    }
}
Comment

PREVIOUS NEXT
Code Example
Rust :: armanriazi•rust•vec 
Rust :: get os name rust 
Rust :: custom errors rust 
Rust :: how to make map in rust language 
Rust :: rust regex split 
Rust :: rustlang char array 
Rust :: rust lang enum 
Rust :: rust undefined size array 
Rust :: rust enter number from keyboard / stdin 
Rust :: armanriazi•rust•error•E0277•the size for values of type `str` cannot be known at compilation time 
Rust :: how to create an integer in rust 
Rust :: rust ceil 
Rust :: Counting bits Kernighan style 
Rust :: armanriazi•rust•concept•dst•or•unsizedtype 
Rust :: armanriazi•substrate•call•dispatchable•func#ensure_signed#frame_system 
Rust :: rust error: failed to run custom build command for python3-sys 
Rust :: rust random float between 0 and 1 
Lua :: Get number of values in a table lua 
Lua :: roblox make kill brick 
Lua :: roblox loop all players 
Lua :: roblox brick color 
Lua :: what is script.Parent? 
Lua :: round to the nearest number lua 
Lua :: lua string to date 
Lua :: roblox lua get game place id 
Lua :: while main.lua 
Lua :: exemple boolean and why it is used 
Lua :: roblox lua 
Matlab :: pyspark dense 
Matlab :: octave get range length 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =