Skip to content

Classes in Rust (no virtual dispatch support or abstract implementations)

Notifications You must be signed in to change notification settings

hydroper/rust.legacyclass

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OOP inheritance for Rust

The oop_inheritance crate provides a flexible Node class that can be subclassed. This crate is implemented given that the Rust language does not include support for struct inheritance.

Example

use oop_inheritance::{Node, class};

class! {
    struct C0: Node {
        // fn x() -> f64
        // fn set_x(x: f64) -> Self
        x: f64 = 0.0,
        // fn x() -> Arc<f64>
        // fn set_x(x: Arc<f64>) -> Self
        ref y: f64 = 0.0,
    }
    // C0::new()
    fn constructor() {
        super();
    }
}

class! {
    struct C1: C0 < Node {}
    fn constructor() {
        super();
    }
}

class! {
    struct C2: C1 < C0 < Node {}
    fn constructor() {
        super();
    }
}

About

Classes in Rust (no virtual dispatch support or abstract implementations)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages