0.1.1 |
|
---|---|
0.1.0 |
|
#29 in #object-oriented
7KB
68 lines
Helio ☀
A library for creating oop-oriented code in rust. Intended originally for my project: Lightfetch.
Features and Benefits 😎
- Create safe, fast, and (hopefully) secure Object-Oriented code in Rust.
- Static instances of types.
Use cases 💡
Annoyed by the fact that Rust is missing a lot of object-oriented features, I decided to create this library to fill a couple of gaps in a lightweight, safe, and fast manner.
Usage 🤔
Create a Static Instance of a Type
#[macro_use]
use helio::{Instance, New};
/// Make sure to use the Clone trait!
#[derive(Clone)]
struct Example {
counter: u32,
}
/// Regular implementation of a struct with any methods you want.
impl Example {
fn new() -> Self {
Example { counter: 0 }
}
fn count(&mut self) {
self.counter += 1;
}
}
/// Implement the Instance trait for Example.
impl Instance for Example {
fn counter(&self) -> u32 {
self.counter
}
}
fn main() {
let example = Example::new(); /// Create a new instance of Example.
example.count(); /// Use that instance to call the count() method and count up.
println!("{}", example.counter()); /// Access the counter and print it.
}
Installing 📦
[dependencies]
helio = "0.1.0"
Show your support 💛
Leave a ⭐ if you like this project.
Contribution 🚩
Found a problem or have a suggestion? Feel free to open an issue or a pull request!
License
This template itself is licensed under the MIT License and includes this as the default project license.