5 releases

0.1.4 Nov 21, 2024
0.1.3 Nov 21, 2024
0.1.2 Nov 21, 2024
0.1.1 Sep 21, 2024
0.1.0 Sep 21, 2024

#595 in Development tools

Download history 253/week @ 2024-09-18 48/week @ 2024-09-25 11/week @ 2024-10-02 1/week @ 2024-10-09 1/week @ 2024-10-16 6/week @ 2024-10-30 8/week @ 2024-11-06 400/week @ 2024-11-20 17/week @ 2024-11-27

427 downloads per month

Apache-2.0

7KB

BOBO

an elegant and powerful rust development tool library

In development, not recommended. The features listed in the documentation are implemented.

Quick Start

Install: cargo add bobo

use bobo::oop::*;

class! {
    Person {
        name: String
        age: u32

        fn greet() {
            println!("{}", format!("Hello, my name is {}.", self.name));
        }
    }
}

fn main() {
    let person = Person {
        name: String::from("Tom"),
    };

    person.greet();
}

A more complex example

Create multiple classes with multiple properties and methods.

use bobo::oop::*;

class! {

    Person {

        name: String
        age: u32

        fn greet() {
            println!("{}", format!("Hello, my name is {}.", self.name));
        }

        fn get_age(years: u32) -> u32 {
            self.age + years
        }
    }

    Animal {

        species: String
        age: u32

        fn speak() {
            println!("The {} makes a sound.", self.species);
        }

        fn age_in_human_years() -> u32 {
            self.age * 7
        }
    }

}

Create a class using a constructor named new:

use bobo::oop::*;

fn main() {
    let person = Person::new("Alice", 30);
    person.greet();
}

class! {
    Person {
        name: String
        age: u32

        fn new(name: &str, age: u32) -> Self {
            Self {
                name: name.to_string(),
                age
            }
        }

        fn greet() {
            println!("{}", format!("I'm {}.", self.name));
        }
    }
}

Dependencies

~220–660KB
~16K SLoC