Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust traits implementation #6

Open
jblachly opened this issue Aug 31, 2021 · 0 comments
Open

Rust traits implementation #6

jblachly opened this issue Aug 31, 2021 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@jblachly
Copy link
Member

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 =)

@jblachly jblachly added the enhancement New feature or request label Aug 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants