1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-03-20 14:31:15 +02:00

33 Commits

Author SHA1 Message Date
Yerkebulan Tulibergenov
252bb62521
Fix typo (#2399)
Fix typo
2024-10-09 03:25:54 +00:00
Jason Lin
d45ec368ef
Update approaches.md (#2317)
I might be missing something, but RAII is generally associated with
programming languages with manual memory management (prominently with
C++, where it originated), so I think it is not very appropriate to have
it mentioned here.
2024-08-27 15:57:52 +00:00
Nicole L
06264e8cc7
Add a note that shared references are Copy (#2107)
Add a note to the `Copy` slide noting that shared references are `Copy`.
A student asked about this today, and it's something I want to remember
to mention in future classes.
2024-05-30 10:19:33 -04:00
Chayim Refael Friedman
5633dd52a7
Vec::new() doesn't allocate (#2026)
So remove it from the list of things to look on that allocate, and
replace with `vec![]`, which does allocate (if given any elements).
2024-04-25 09:40:36 -04:00
Nicole L
59d63a6e89
Simplify the example code for Clone (#2001)
The previous example code for the `Clone` slide was a bit too complex in
a way that obscured the fundamental point. I've replaced it with the
`say_hello` example from the previous slide, but updated to demonstrate
how cloning can address the borrow checker error. I also added a speaker
note to mention that `Clone` performs a deep copy, which might be
different from what students are used to if they come from a language
like Python that does shallow copies by default.
2024-04-19 10:18:31 -04:00
Attila-Mihaly Balazs
ec5d4afa19
Update move.md (#1944)
Fix the String length (and capacity) to make it less confusing.
2024-03-26 13:31:39 +00:00
Yuri Astrakhan
9404a22b15
Make diagram consistent with code (#1855) 2024-03-06 17:12:09 +01:00
Gergely Risko
adaa04f961
Change String representation to actual (#1817)
Tested with rust 2015, 2018, 2021 and 2024, on amd64 musl, amd64 glibc
and aarch64 musl, all of them represent Strings with (ptr, capacity,
len).

This is an internal implementation detail, that shouldn't be exposed
anyway, so it's no big deal, but in the speaker notes, we provide a
debugging tool for demonstration purposes, so at least that should have
a correct output.
2024-02-15 17:24:19 -05:00
Dustin J. Mitchell
9f67c9b0e7
Adjust morning-session timings downward (#1786)
Based on feedback from @marshallpierce that mornings took about 2.5
hours, this adjusts a bunch of the morning times downward to try to
match that. In other words, this is trying to make the times in the
course more accurate, rather than reducing the amount of time available
for these slides.

This also updates the `course-schedule` tool to be able to show
per-segment timings.
2024-02-06 15:48:56 -05:00
Martin Geisler
c9f66fd425
Format all Markdown files with dprint (#1157)
This is the result of running `dprint fmt` after removing `src/` from
the list of excluded directories.

This also reformats the Rust code: we might want to tweak this a bit in
the future since some of the changes removes the hand-formatting. Of
course, this formatting can be seen as a mis-feature, so maybe this is
good overall.

Thanks to mdbook-i18n-helpers 0.2, the POT file is nearly unchanged
after this, meaning that all existing translations remain valid! A few
messages were changed because of stray whitespace characters:

     msgid ""
     "Slices always borrow from another object. In this example, `a` has to remain "
    -"'alive' (in scope) for at least as long as our slice. "
    +"'alive' (in scope) for at least as long as our slice."
     msgstr ""

The formatting is enforced in CI and we will have to see how annoying
this is in practice for the many contributors. If it becomes annoying,
we should look into fixing dprint/check#11 so that `dprint` can annotate
the lines that need fixing directly, then I think we can consider more
strict formatting checks.

I added more customization to `rustfmt.toml`. This is to better emulate
the dense style used in the course:

- `max_width = 85` allows lines to take up the full width available in
our code blocks (when taking margins and the line numbers into account).
- `wrap_comments = true` ensures that we don't show very long comments
in the code examples. I edited some comments to shorten them and avoid
unnecessary line breaks — please trim other unnecessarily long comments
when you see them! Remember we're writing code for slides 😄
- `use_small_heuristics = "Max"` allows for things like struct literals
and if-statements to take up the full line width configured above.

The formatting settings apply to all our Rust code right now — I think
we could improve this with https://github.com/dprint/dprint/issues/711
which lets us add per-directory `dprint` configuration files. However,
the `inherit: true` setting is not yet implemented (as far as I can
tell), so a nested configuration file will have to copy most or all of
the top-level file.
2023-12-31 00:15:07 +01:00
Dustin J. Mitchell
9563f055e2
Minor updates based on instruction (#1583)
This contains some minor updates from #1565.

---------

Co-authored-by: Marshall Pierce <575695+marshallpierce@users.noreply.github.com>
2023-12-13 12:51:34 +00:00
Marshall Pierce
6c5061bb90
Various small fixes (#1556)
Plus one more substantial comment on casting.
2023-12-05 18:06:42 -05:00
Dustin J. Mitchell
6d19292f16
Comprehensive Rust v2 (#1073)
I've taken some work by @fw-immunant and others on the new organization
of the course and condensed it into a form amenable to a text editor and
some computational analysis. You can see the inputs in `course.py` but
the interesting bits are the output: `outline.md` and `slides.md`.

The idea is to break the course into more, smaller segments with
exercises at the ends and breaks in between. So `outline.md` lists the
segments, their duration, and sums those durations up per-day. It shows
we're about an hour too long right now! There are more details of the
segments in `slides.md`, or you can see mostly the same stuff in
`course.py`.

This now contains all of the content from the v1 course, ensuring both
that we've covered everything and that we'll have somewhere to redirect
every page.

Fixes #1082.
Fixes #1465.

---------

Co-authored-by: Nicole LeGare <dlegare.1001@gmail.com>
Co-authored-by: Martin Geisler <mgeisler@google.com>
2023-11-29 16:39:24 +01:00
Martin Geisler
f94daaea73
Add “More to Explore” sections (#1369)
From a discussion in #1313.
2023-10-16 15:42:07 +02:00
Martin Geisler
d0e0e5c1af
Skip some untranslatable code blocks (#1258)
This builds on the work of @dyoo in
https://github.com/google/mdbook-i18n-helpers/pull/69: by adding a
special `<!-- mdbook-xgettext: skip -->` comment, we can skip the
following code block.

I also modified a few code blocks to remove translatable text: variable
names are not expected to be translated, so it’s fine to have a line
with `println!("foo: {foo}")` in the code block.

This PR removes 36 messages from the POT file. The number of lines drop
by 633 (3%).

Part of #1257.
2023-09-26 17:04:46 +02:00
Martin Geisler
55f6a8428e
Remove memory management comparison (#1049)
This is a follow-up to #998 and the discussion in #1049. The
comparison page is now gone: like @randomPoison said, it feels
redundant and I also mostly skip over it when teaching the class.

I also took out some duplication in the Rust memory management page. I
would be up for simplifying the whole chapter down to one or two
slides as @djmitche suggests: that would leave us with more time for
covering ownership.
2023-09-01 11:32:48 -04:00
Dominik Maier
486458c72d
Memory Management: Rework Scope-based Cons (#998)
* Memory Management: Add classic ARC issues to Comparison

* replaced uaf reference (which needs misuse in C++)
2023-07-18 08:51:52 -07:00
Dominik Maier
3f1a8d8ca1
Memory Management: Leaks are bad, RCE is worse (#997)
Leaks are bad, RCE is worse
2023-07-17 22:36:14 -07:00
Dominik Maier
aabe0c0a96
'Stack Memory' slide isn't really showing stack memory (#996) 2023-07-17 22:35:20 -07:00
Wojtek Marczenko
4413b6a28f
Update C manual memory management example (#902)
In C (as opposed to C++) the explicit cast from void* to int* is not required. It is also not idiomatic to do so in C code.

Actual C codebase would use `malloc()` without the cast, and a C++ one (when not using abstractions) a `new int[n]` - both a bit cleaner and less verbose than this example.
2023-07-05 09:37:07 -04:00
Martin Geisler
eb6850a1d0
Clarify what "it" is in rust.md (#855) 2023-06-22 14:28:14 +00:00
Charisee Chiw
59d3d7f625
Indent code in speaker notes (#476)
* Indent code in speaker notes

#475

* Update stack.md

* Update destructuring-arrays.md

* Update hashmap.md

* Update traits.md
2023-03-11 14:12:32 -08:00
gendx
ce19841249
Add highly-unsafe speaker notes to inspect the memory layout of string. (#341) 2023-02-09 07:47:15 +01:00
Yauheni Baltukha
f118a78ef2 Fix typo in rust.md 2023-01-14 01:45:36 +01:00
Fabian Bornhofen
45e57e9359
Capitalization in stack.md 2023-01-12 11:51:37 +01:00
Fabian Bornhofen
7203bb8a65
Capitalization in src/memory-management/rust.md 2023-01-12 11:50:28 +01:00
Brandon Pollack
f750f75db6 stackheap notes 2023-01-12 11:12:53 +09:00
Martin Geisler
150e78a3f9
Rephrase destructor delays
After a discussion, it seems singular works well.
2022-12-31 12:33:57 +01:00
Kane York
de7d91752f
comparison: copyedit 'delays' to 'delayed'
This is the correct grammatical form for the bullet point, it expands into "Destructors [of objects are] delayed."
2022-12-27 14:13:10 -08:00
Patrick Decat
b5cbe4896b
Remove misplaced "calls" 2022-12-26 11:22:00 +01:00
Reilly Grant
16d4d2c92f
Fix C array syntax in memory-management/manual.md
Heap-allocated arrays in C use `int*` instead of `int[]`.
2022-12-22 21:58:08 -08:00
Andrew Pollack
6809d4ef78
Minor punctuation update 2022-12-21 09:33:44 -08:00
Martin Geisler
c212a473ba Publish Comprehensive Rust 🦀 2022-12-21 16:38:28 +01:00