Crates.io | helio |
lib.rs | helio |
version | 0.1.1 |
source | src |
created_at | 2022-08-26 22:12:34.731415 |
updated_at | 2022-08-27 12:20:50.862604 |
description | 📚 A library for creating oop-oriented code in rust. Intended for use in 'lightfetch'. |
homepage | https://bwte.ml/ |
repository | https://github.com/bwte/helio |
max_upload_size | |
id | 653076 |
size | 13,228 |
A library for creating oop-oriented code in rust. Intended originally for my project: Lightfetch.
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.
#[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.
}
[dependencies]
helio = "0.1.0"
Leave a ⭐ if you like this project.
Found a problem or have a suggestion? Feel free to open an issue or a pull request!
This template itself is licensed under the MIT License and includes this as the default project license.