rust_class

Crates.iorust_class
lib.rsrust_class
version0.1.0
sourcesrc
created_at2021-09-20 10:55:09.945482
updated_at2021-09-20 10:55:09.945482
descriptionClass in rust
homepagehttps://github.com/AzerothA/rust-class
repository
max_upload_size
id453923
size3,247
Azeroth (AzerothA)

documentation

README

rust-class

Class in rust

Example usage

#[macro_use]
use rust_class::class;

class! {
    class Person {
        [String name];

        Self new(name: String) {
            Self {
                name: name,
            }
        }

        String get_name(self) {
            self.name
        }
    }

    class Sum {
        [
            u8 num1
            u8 num2
        ];

        Self new(num1: u8, num2: u8) {
            Self {
                num1: num1,
                num2: num2,
            }
        }

        u8 sum(self) {
            self.num1 + self.num2
        }
    }
}

fn main() {
    let person_test = Person::new("Alice".to_string());
    println!("{}", hl_test.get_name());

    let sum_test = Sum::new(1, 4);
    println!("{}", an_test.sum());
}
Commit count: 0

cargo fmt