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 :: rust hashmap 
Rust :: rust option 
Rust :: rust global variables 
Rust :: new rust project with cargo 
Rust :: const generics in rust 
Rust :: armanriazi•rust•vec 
Rust :: rust•armanriazi•borrowchecker•lifetime 
Rust :: rust regex split 
Rust :: error handling rust 
Rust :: armanriazi•rust•unsafe•rawpointer 
Rust :: rust lang expected item found let 
Rust :: rust•armanriazi•strring•vs•str 
Rust :: armanriazi•rust•reference•dangle 
Rust :: rust•armanriazi•error•value used here after move 
Rust :: rust•armanriazi•error•cannot be formatted with the default formatter 
Rust :: armanriazi•rust•ref•move 
Rust :: armanriazi•rust•thread•channel 
Rust :: rust hashset 
Lua :: How to make an NPC chat in roblox 
Lua :: user input lua 
Lua :: luau loop players 
Lua :: roblox brick color 
Lua :: grepper lua 
Lua :: for loop roblox 
Lua :: how to access an index of a table lua 
Lua :: lua hash table length 
Lua :: wails build 
Lua :: lua print table as string 
Matlab :: matlab read from txt file 
Matlab :: matlab function files 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =