Search
 
SCRIPT & CODE EXAMPLE
 

RUST

class in rust

// Rust does not have class
// Rust have `struct` and `impl`, they have the same class performance

struct Person {
	name: String,
    age: usize
}

impl Person {
	// This associated function have the same `constrator` performance
	fn new(name: String, age: usize) -> Self {
    return Self {name, age};
    }
    fn get_name(&self) -> String {
    	return self.name;
    }
    fn change_name(&mut self, new_name: String) -> () {
    	self.name = new_name;
    }
}
Comment

PREVIOUS NEXT
Code Example
Rust :: rust initialize struct 
Rust :: rust regex split 
Rust :: rust comment types 
Rust :: where in Rust 
Rust :: does rust support classes 
Rust :: armanriazi•rust•unsafe•rawpointer 
Rust :: armanriazi•rust•string 
Rust :: armanriazi•rust•error•cannot use the `?` operator in a function that returns `()` 
Rust :: hwllo world in rust 
Rust :: armanriazi•rust•oop 
Rust :: armanriazi•rust•unsafe•extern•mangling 
Rust :: Counting bits Kernighan style 
Rust :: rust-analyzer tab space 
Rust :: armanriazi•rust•thread•spawning 
Rust :: armanriazi•rust•refactor•flowcontrol•match•unwrap_or_else 
Rust :: rust hashset 
Lua :: lua how to get random object from a table 
Lua :: roblox send message script 
Lua :: luau how to loop through all players 
Lua :: remote function unable to cast value to object 
Lua :: roblox pairs 
Lua :: lua string count occurrence 
Lua :: append to array lua 
Lua :: how to make a welcome badge roblox lua 
Lua :: roblox get how many players in server 
Lua :: check player role in group 
Lua :: lua how to default value if nil 
Matlab :: find location of max value in array matlab 
Matlab :: print hello world n times in matlab 
Basic :: personal access token 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =