Skip to content

Model::default vs 0 #57

Description

@MartinKavik

Chat - #documentation

Tock: just started working through the new docs. Am on App 1: Counter / Init. You just got done on the previous page talking about how you shouldn't implement Default for Model, then the first thing on this page I see is Model::default(). Now I know it's because it's an int alias, so we're getting i32::default(), but as someone who might have missed that, it's jarring. Maybe just have the init() return 0 directly?

MartinKavik: I was fighting with myself whether there should be:
A) Model::default()
B) 0
C) Change Model to something like:
struct Model {
click_count: u32
}
because a type alias as Model is an edge-case.
So perhaps we should change it to 0. Do we want to change it also in README and /examples/counter?
Also it doesn't break the rule that we shouldn't implement Default for Model - it has been already implemented by Rust std..

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions