Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/moluopro/bobo
Under construction, please ignore
https://github.com/moluopro/bobo
Last synced: 15 days ago
JSON representation
Under construction, please ignore
- Host: GitHub
- URL: https://github.com/moluopro/bobo
- Owner: moluopro
- License: apache-2.0
- Created: 2024-10-15T02:22:34.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2024-11-21T03:18:58.000Z (about 1 month ago)
- Last Synced: 2024-11-21T03:20:05.358Z (about 1 month ago)
- Language: Rust
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## 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`
```rust
use bobo::oop::*;class! {
Person {
name: String
age: u32fn 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.
```rust
use bobo::oop::*;class! {
Person {
name: String
age: u32fn greet() {
println!("{}", format!("Hello, my name is {}.", self.name));
}fn get_age(years: u32) -> u32 {
self.age + years
}
}Animal {
species: String
age: u32fn 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`:
```rust
use bobo::oop::*;fn main() {
let person = Person::new("Alice", 30);
person.greet();
}class! {
Person {
name: String
age: u32fn new(name: &str, age: u32) -> Self {
Self {
name: name.to_string(),
age
}
}fn greet() {
println!("{}", format!("I'm {}.", self.name));
}
}
}
```