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

add typestates assignment #164

Open
miguelraz opened this issue Oct 4, 2022 · 0 comments
Open

add typestates assignment #164

miguelraz opened this issue Oct 4, 2022 · 0 comments

Comments

@miguelraz
Copy link
Contributor

miguelraz commented Oct 4, 2022

Rework cool example from the RfR book by

  • Task 1:starting with a toy example like
struct Grounded;
struct Launched;
// and so on
struct Rocket<Stage = Grounded> {
    stage: std::marker::PhantomData<Stage>,
}
impl Default for Rocket<Grounded> {}
    impl Rocket<Grounded> {
    pub fn launch(self) -> Rocket<Launched> { }
}
impl Rocket<Launched> {
    pub fn accelerate(&mut self) { }
    pub fn decelerate(&mut self) { }
}
impl<Stage> Rocket<Stage> {
    pub fn color(&self) -> Color { }
    pub fn weight(&self) -> Kilograms { }
}
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