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

Introduce Rollable, a trait for arbitrary types #12

Open
jakoschiko opened this issue Jul 6, 2024 · 1 comment
Open

Introduce Rollable, a trait for arbitrary types #12

jakoschiko opened this issue Jul 6, 2024 · 1 comment

Comments

@jakoschiko
Copy link
Owner

I lost hope that I can use a trait from another crate for that purpose:

So let's introduce an own trait (+ derive macro). It could look like this:

pub trait Rollable {
    fn die() -> impl Die<Self>;
    fn uses_limit() -> bool;
}

#[derive(Rollable)]
struct MyStruct;

Remarks:

  • Distinguishable name to prevent confusion with other crates.
  • Rollable::die allows nice integration with exiting combinators.
  • Rollable::uses_limit allows to implement a reliable strategy to respect Limit for the whole data structure.
  • Recursive data structures are a big problem for arbitrary::Arbitrary. I can provide a better experience by splitting up Limit when recursing into the data structure.
@jakoschiko
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant