Coder Social home page Coder Social logo

Suggestions: Misc about comprehensive-rust HOT 2 OPEN

google avatar google commented on August 25, 2024
Suggestions: Misc

from comprehensive-rust.

Comments (2)

mgeisler avatar mgeisler commented on August 25, 2024

Hey, just a quick comment for one part above:

The getters and setters here aren't very idiomatic. First of all, nothing here is public -- everything must be in the same module -- so you'd just access the fields directly. Second of all, instead of a getter an infallible setter, if the struct was public, you'd probably just make those fields public too. If the fields actually have invariants, the setters shouldn't be infallible, but instead return a Result<_, _>.

More generally, it may give the impression that using getters and setters is idiomatic (even in the same module).

Yes, I agree with you, I should change these getters to do something more complicated.

Perhaps note this list of receivers is non-exhaustive. E.g. Box.

Yeah, thanks!

from comprehensive-rust.

fw-immunant avatar fw-immunant commented on August 25, 2024

I think you should show the Option and Result definitions here. They'll see the variants everywhere in Rust.

When teaching, the definition of Option often comes up before the standard library slides are even reached. In any case, whenever going through the standard library slides the slide provides an introduction to the type with usage context and then the standard library docs are the destination for the precise definition if public and to dive deeper into the available methods. See #2248.

Clarify that a HashMap doesn't have to be keyed with a &str or String (unlike a JSON object, say).

This becomes clear on the next slide as well as in the standard library docs where the K, V, and S type parameters are all worth discussing.

The getters and setters here aren't very idiomatic.

These are no longer present, but this exercise could admittedly use some work (#1513).

I don't know that "omitted" is the right term for mod in_another_file;.

To me it makes sense--the body of the mod item is not present in this file, i.e. it is omitted.

from comprehensive-rust.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.