From 43bfc94b4f9bef729a729701351922f5223b5ff8 Mon Sep 17 00:00:00 2001 From: lauti7 Date: Fri, 31 Mar 2023 21:41:35 -0300 Subject: [PATCH 1/3] errata --- _errata/print01-ch03-destructors.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 _errata/print01-ch03-destructors.md diff --git a/_errata/print01-ch03-destructors.md b/_errata/print01-ch03-destructors.md new file mode 100644 index 0000000..5e43256 --- /dev/null +++ b/_errata/print01-ch03-destructors.md @@ -0,0 +1,11 @@ +--- +chapter: 3 +page: 47 +kind: wording +reporter: lauti7 +date: 2023-03-31 +--- +You says: +"The second workaround is to make each of your fields takeable. You can "take" an Option by replacing it with None (which is what Option:: take does), but you can do this with many other types as well. For example, you can Take a vecOr HashMap by simply replacing them with their cheap-to-construct default values--std::mem::take is your friend here. This approach works great if your types have sane "empty" values but gets tedious if you must wrap nearly every field in an Option and then modify every access of those fields with a matching unwrap." + +I think that in the last sentence "This approach..." you start referring to the `std::mem::take` because you talk about "empty" values, and what `std::mem::take` does is to replace the value with the `Default` implementation and then you end talking about `Option` saying "but gets tedious ...". I think the last sentence is not pretty clear this way. Maybe I'm misunderstanding something \ No newline at end of file From 61237e43e06fd14b0990ec3d11862a2d5f1d07c4 Mon Sep 17 00:00:00 2001 From: lauti7 Date: Fri, 31 Mar 2023 21:43:04 -0300 Subject: [PATCH 2/3] edit --- _errata/print01-ch03-destructors.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_errata/print01-ch03-destructors.md b/_errata/print01-ch03-destructors.md index 5e43256..6857bef 100644 --- a/_errata/print01-ch03-destructors.md +++ b/_errata/print01-ch03-destructors.md @@ -8,4 +8,4 @@ date: 2023-03-31 You says: "The second workaround is to make each of your fields takeable. You can "take" an Option by replacing it with None (which is what Option:: take does), but you can do this with many other types as well. For example, you can Take a vecOr HashMap by simply replacing them with their cheap-to-construct default values--std::mem::take is your friend here. This approach works great if your types have sane "empty" values but gets tedious if you must wrap nearly every field in an Option and then modify every access of those fields with a matching unwrap." -I think that in the last sentence "This approach..." you start referring to the `std::mem::take` because you talk about "empty" values, and what `std::mem::take` does is to replace the value with the `Default` implementation and then you end talking about `Option` saying "but gets tedious ...". I think the last sentence is not pretty clear this way. Maybe I'm misunderstanding something \ No newline at end of file +I think that in the last sentence "This approach..." you start referring to the `std::mem::take` because you talk about "empty" values, and what `std::mem::take` does is to replace the value with the `Default` implementation and then you end talking about `Option` saying "but gets tedious ...". I think the last sentence is not pretty clear this way. \ No newline at end of file From 7622b2bb57fc1aab13d833984262cb34d2c95206 Mon Sep 17 00:00:00 2001 From: Lautaro Bustos Date: Fri, 24 Jan 2025 09:19:41 -0300 Subject: [PATCH 3/3] Update _errata/print01-ch03-destructors.md Co-authored-by: Jon Gjengset --- _errata/print01-ch03-destructors.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/_errata/print01-ch03-destructors.md b/_errata/print01-ch03-destructors.md index 6857bef..77994d3 100644 --- a/_errata/print01-ch03-destructors.md +++ b/_errata/print01-ch03-destructors.md @@ -5,7 +5,9 @@ kind: wording reporter: lauti7 date: 2023-03-31 --- -You says: -"The second workaround is to make each of your fields takeable. You can "take" an Option by replacing it with None (which is what Option:: take does), but you can do this with many other types as well. For example, you can Take a vecOr HashMap by simply replacing them with their cheap-to-construct default values--std::mem::take is your friend here. This approach works great if your types have sane "empty" values but gets tedious if you must wrap nearly every field in an Option and then modify every access of those fields with a matching unwrap." +The paragraph that reads, in part: +> The second workaround is to make each of your fields takeable. You can "take" an Option by replacing it with None (which is what `Option::take` does), but you can do this with many other types as well. For example, you can take a Vec or HashMap by simply replacing them with their cheap-to-construct default values — `std::mem::take` is your friend here. This approach works great if your types have sane "empty" values but gets tedious if you must wrap nearly every field in an Option and then modify every access of those fields with a matching unwrap. -I think that in the last sentence "This approach..." you start referring to the `std::mem::take` because you talk about "empty" values, and what `std::mem::take` does is to replace the value with the `Default` implementation and then you end talking about `Option` saying "but gets tedious ...". I think the last sentence is not pretty clear this way. \ No newline at end of file +This paragraph is technically correct, but somewhat hard to follow, because "empty" and default are not necessarily the same thing. Some types implement `Default`, but that value is not technically "empty" (`usize` for example). The sentence should instead read: + +> [..] have sane default values (like an empty map or a `None`) but gets tedious if you must wrap nearly every field in something like an `Option` [..] \ No newline at end of file