Fix a few statements in the Fundamentals material - #3288
Open
cindykrafft wants to merge 1 commit into
Open
cindykrafft wants to merge 1 commit into
cindykrafft wants to merge 1 commit into
Conversation
- RefCell: a borrowed RefCell's Debug output is
`RefCell { value: <borrowed> }` (rustc 1.94.1), not "{borrowed}".
- Modules: the attribute is `#[doc(hidden)]`, not `#[doc_hidden]`.
- Destructuring structs: the struct on the slide is `Move`.
- Protobuf exercise: `parse_varint` stopped after 7 bytes and called
longer varints invalid, but protobuf varints can be up to 10 bytes
(e.g. negative int32 values). Accept up to 10 bytes.
- extern-c: functions in an `unsafe extern` block without a
`safe`/`unsafe` qualifier compile and are unsafe to call.
- Link Unsafe Rust at chapter 20.1 of the Book (19.1 now redirects).
- Typos: "known as", "collected into", "into the".
Claude-Session: https://claude.ai/code/session_01X59fWmqnA4Nmb9rggkTP7n
Collaborator
|
Hi, could you say a bit about these changes in your own words? |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Small corrections, each checked with rustc 1.94.1 (edition 2024) or against the linked source. They don't touch the files changed in open PRs (#3243, #3281–#3285).
RefCell"just shows the message"{borrowed}"". Withlet c = RefCell::new(5); let _m = c.borrow_mut(); println!("{c:?}");I getRefCell { value: <borrowed> }.#[doc_hidden]→#[doc(hidden)].#[doc_hidden]gives "cannot find attributedoc_hiddenin this scope".Movement", but the struct on the slide isMove.parse_varintread at most 7 bytes, with the comment "More than 7 bytes is invalid". The protobuf encoding docs say varints use "between one and ten bytes", and that negativeintNvalues use all ten. With the 7-byte limit, aPersonwithid= -1 encoded as protobuf does it (0x10followed byff ff ff ff ff ff ff ff ff 01) panics with "Too many bytes for varint". I changed the limit to 10. The existing tests pass, and a 10-byte varint foru64::MAXnow parses. If the 7-byte limit was a deliberate simplification, I can change only the comment instead.externblock must be marked assafeorunsafe". The Reference says "A function declared in an extern block is implicitly unsafe unless the safe function qualifier is present", and an unqualified declaration compiles. I reworded it to "can be marked", and added that unqualified functions are unsafe to call. This may have been a deliberate simplification; please drop it if so.cargo test,mdbook testanddprint checkpass.