Skip to content

Keyword "super" is used in solution for 03_ticket_v1/03_modules but is not explained good in book #230

@Galser

Description

@Galser

There is an exercise accompanying 03_ticket_v1/03_modules and solution contains usage of special path part super :

    // TODO: Make this code compile, either by adding a `use` statement or by using
    //  the appropriate path to refer to the `Ticket` struct.
    use super::Ticket;

While in the book itself when unexperienced person reading a paragraph it looks like this :

You can compose the path in various ways:

  • starting from the root of the current crate, e.g. crate::module_1::MyStruct
  • starting from the parent module, e.g. super::my_function
  • starting from the current module, e.g. sub_module_1::MyStruct

So it's not clear - was super the name of parent module? Or is it some kind of "special" case where module is inlined in code file? It is maybe a small thing, but it's going to cause some people scratching their heads :-) Maybe there can be a hint/link to https://doc.rust-lang.org/rust-by-example/mod/super.html ?

Thank you!

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