Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update primitives.md #1798

Closed

Conversation

daniel-web-developer
Copy link

Since tuples can hold values of different types, I think it would be important to make it obvious they can do so.

Right now, the book is saying "Tuples like (1, true).". This might make the impression that tuples are limited to holding values of the same type, so that's why I'm proposing to change 1 to a 2, making it "Tuples like (2, true).".

Since tuples can hold values of different types, I think it would be important to make it obvious they can do so.
@rustbot
Copy link
Collaborator

rustbot commented Jan 8, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @marioidival (or someone else) soon.

@AndreasHuber
Copy link
Contributor

1 and true are of different types, i32 and bool respectively, but 2 is an i32 just like 1. Thus, the proposal presents no meaningful change to the example and I would suggest closing this PR.

@daniel-web-developer
Copy link
Author

1 and true are of different types, i32 and bool respectively, but 2 is an i32 just like 1. Thus, the proposal presents no meaningful change to the example and I would suggest closing this PR.

They're different types, but as a beginner in Rust, I couldn't tell that at first. The change I'm proposing would save other beginners from the same confusion (since true can be represented as 1 in lots of other languages).

@marioidival
Copy link
Member

I think the best decision here is closing the PR because in the same page we are introducing to the users to the scalar types in Rust:

# Primitives
Rust provides access to a wide variety of `primitives`. A sample includes:
### Scalar Types
* Signed integers: `i8`, `i16`, `i32`, `i64`, `i128` and `isize` (pointer size)
* Unsigned integers: `u8`, `u16`, `u32`, `u64`, `u128` and `usize` (pointer
  size)
* Floating point: `f32`, `f64`
* `char` Unicode scalar values like `'a'`, `'α'` and `'∞'` (4 bytes each)
* `bool` either `true` or `false`
* The unit type `()`, whose only possible value is an empty tuple: `()`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants