Replies: 3 comments
-
Hi @QuineDot, I converted this to a discussion from #69 — discussions have threads, so we can discuss each point in it's own little tree. It's like we've invented Usenet or mailing lists all over again 😄 |
Beta Was this translation helpful? Give feedback.
-
Interesting point about the
With that, I guess a I like this way of thinking since it circumvents the whole question about what it means for a type ( I also don't think we should try to write this out in full details — it's something the instructor will have to discuss with the students during class. |
Beta Was this translation helpful? Give feedback.
-
That's a fair point... I should not have used the word simply here 😄 We do talk about how you implement one method ( |
Beta Was this translation helpful? Give feedback.
-
You make a direct comparison between Rust and C++ references, but Rust references are more similar to pointers in many ways. I see people coming from C++ and being confused by this on the forums, so making the direct comparison may be counter-productive.
The compile time guarantees are guaranteed for safe Rust with sound dependencies. Worth pointing out since you have a section on
unsafe
. Most of them are UB if they do get compiled.There are no
NULL
references, but there areNULL
pointers.(More a suggestion:) Although foot-noted, the memory leak seemed out-of-place to me in this list. Perhaps the
Mutex
lock too. Both, I guess, fall under RAII.Here you say
But what you actually mean is "if you want to return different types implementing a trait".
The rest of this is suggestion territory, but here you should point out how different the argument position (APIT) and return position (RPIT) uses are.
if/else
And then when you get to returning
Box<dyn Trait>
you can compare and contrast with RPIT.You say
But they're not really packed, it's more that the variants can share storage because it's a tagged union; only one variant is "active" at a time. (And
repr(packed)
is something else entirely.)Also, the layout (size optimization) is only guaranteed in very specific circumstances. Perhaps mention in general that most Rust data structures have no layout guarantees. You mention niche optimization here too; that almost meets the guaranteed case (as far as I'm aware of it existing), but not quite. So the niche optimization is not guaranteed for the example.
You say
First, there are 74 more other methods so far, so it says a lot more than that.
But also, there's nothing that keeps you from calling
next
after you get aNone
back. And unless your iterator is fused, nothing that says you'll never get aSome(_)
after you see aNone
.You say
But
Rc
andArc
are often referred to as "shared owneship". Even more nit-picky, aVec
(say) can be in a single variable binding, but owns multiple values.I don't have a good suggestion on how to word all this while getting across your original point and not being confusing though.
Beta Was this translation helpful? Give feedback.
All reactions