Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Steve Klabnik
    @steveklabnik
    @dwbrite yes!
    awesome, i will look at those soon :D
    Devin Brite
    @dwbrite
    @steveklabnik Do you think I should move () back to scalar types and add a comment about it? Perhaps a new line after the unordered list?
    Steve Klabnik
    @steveklabnik
    Yeah, that sounds like a good idea
    it is a special case/kinda weird thing
    so i like the idea of calling that out explicitly
    Devin Brite
    @dwbrite
    Great, will do.
    Devin Brite
    @dwbrite
    Is () scalar in a similar way that (i32) could be considered scalar?
    Steve Klabnik
    @steveklabnik
    "scalar" means "not a collection". so yeah, both of those represent a single value
    Devin Brite
    @dwbrite
    Gotcha. Thank you!
    Steve Klabnik
    @steveklabnik
    It'd be (i32,) for a single-element tuple btw
    Devin Brite
    @dwbrite

    It'd be (i32,) for a single-element tuple btw

    But it's not strict about the comma?

    QuietMisdreavus
    @QuietMisdreavus
    no, the comma is necessary to make it a single-element tuple
    (i32) is just i32
    Devin Brite
    @dwbrite
    That makes sense. Thank you
    QuietMisdreavus
    @QuietMisdreavus
    well, it's that way for expressions, i don't remember if you can wrap types like that to have it work the same way
    Devin Brite
    @dwbrite

    I just tested it and it looks like it does:

    let something = ();
    let something2: (i32) = (2);
    let something3: (i32,) = (3,);
    
    println!("{:?} {} {:?}", something, something2, something3);

    () 2 (3,)

    Steve Klabnik
    @steveklabnik
    :+1:
    QuietMisdreavus
    @QuietMisdreavus
    nice, thanks for double-checking that :heart:
    Devin Brite
    @dwbrite

    and the unit type (), whose only value is also ()

    Should this be rephrased? Maybe to "[...] whose only value is an empty tuple"? That's clearer, but newcomers might not know what that means...

    Steve Klabnik
    @steveklabnik
    why not both?
    and the unit type (), whose only value is also an empty tuple, ()
    maybe?
    Devin Brite
    @dwbrite

    and the unit type (), whose only possible value is an empty tuple: ()

    I like it.

    Steve Klabnik
    @steveklabnik
    :+1:
    Devin Brite
    @dwbrite

    Despite the value of a unit type being a tuple, it is not considered a
    compound type because it does not contain multiple values.

    Does that make sense?

    Steve Klabnik
    @steveklabnik
    it does.
    here's another random idea, dunno if it's good or not
    what if we explained tuples as a third type, that's sometimes scalar, sometimes compound
    Devin Brite
    @dwbrite
    I like it. The only "catch" is that then arrays would be kind of lonely in the compound section, which isn't really a big deal
    Steve Klabnik
    @steveklabnik
    fair. what's interesting is
    arrays also have the same problem
    so, maybe we leave it all under compound types
    we add a note at the bottom that a single-length compund type is sorta like a scalar
    and call out () as an example
    ... docs are hard :smile:
    Devin Brite
    @dwbrite
    And then we'll have rust-lang/rust-by-example#1337: "The primitives section calls () a single-length compound! :worried:" ahahahahaha
    Steve Klabnik
    @steveklabnik
    hahahhaha :/
    Devin Brite
    @dwbrite
    Docs are hard :)
    Thank you for talking it out with me
    Steve Klabnik
    @steveklabnik
    thank you too; talking stuff out is a great way to make things better :smile:
    Devin Brite
    @dwbrite
    Maybe the information about compound types being potentially scalar doesn't need to be included

    It may be covered by this:

    Despite the value of a unit type being a tuple, it is not considered a
    compound type because it does not contain multiple values.

    Steve Klabnik
    @steveklabnik
    yeah, that's fair
    Devin Brite
    @dwbrite
    Alright, great!
    And we're all set. Thank you!
    Steve Klabnik
    @steveklabnik
    :+1: :heart:
    Aravindh Sridharan
    @hardvain
    In the page https://rustbyexample.com/scope/borrow/freeze.html , shouldnt the compiler error message be assignment to immutably borrowed _mutable_integer occurs hereinstead of assignment to borrowed _mutable_integer occurs here
    My bad. Found the reason. Kindly ignore the above message.
    Devin Brite
    @dwbrite
    Hello, I'm still around - just busy. Next week I get a break, so I'll be back soon!
    Steve Klabnik
    @steveklabnik
    @dwbrite no worries! :)