Learning Rust with "Too Many Linked Lists" (Episode 1) - Getting Started

Поделиться
HTML-код
  • Опубликовано: 23 янв 2025
  • НаукаНаука

Комментарии • 2

  • @ssokolow
    @ssokolow 4 года назад

    I haven't seen part 2 yet, so you might know theis but here's why you don't need to write Option::Some and Option::None.
    1. To avoid needless repetition, you can *use* individual variants of an enum to bring them into scope directly.
    2. The compiler automatically injects a wildcard *use* for *std::prelude* and one of the things that does is *use* the *Some* and *None* variants for you.
    See doc.rust-lang.org/std/prelude/index.html for what else it does.
    Also, I don't have time to scrub back through the beginning of your video to check but, if you weren't aware, there's a field for an SPDX license expression in Cargo.toml:
    doc.rust-lang.org/cargo/reference/manifest.html#the-license-and-license-file-fields

    • @paulbarker5505
      @paulbarker5505  4 года назад

      Thanks for the feedback! I think I understand now why I can just use `Some` and `None` without the `Option::` prefix. As far as the license field in Cargo.toml, I think I'll cover this in the 4th episode since I've already recorded the 3rd one.