Skip to content

Rust traits implementation #6

@jblachly

Description

@jblachly

Consider a third Rust implementation:

pub struct ZBHO {
    start: u64,
    end: u64
}
...3 more

then define Traits for basis and openness. IIUC, In this way you could define impl for functions which have different implementations depending on e.g. openness, like len, with full compile time monomorphization and no runtime type checks as in our existing two implementations

i imagine something like

pub trait DifferentialBehavior {
    fn len(&self) -> u64;
}

impl DifferentialBehavior for ZBHO {
    fn len(&self) -> u64 {
        self.end - self.start
    }
}
// and same exact impl for OBHO

In fact you may be able to combine this strategy with your zero sized type parameters to reduce duplication and instead write something like

impl<T: HalfOpen> for Interval<B, T>

although I'm not sure how you specialize on just one type. probably still works.

if you can do this I have to change the part of the paper explaining the drawbacks to the Rust implementations include runtime checks =)

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions