You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are unmodified code from stack implementation after the "Let's steal some iterator impls from the stack:"
Compiler yells with:
error[E0599]: no method named `as_deref` found for raw pointer `*mut fifth::Node<T>` in the current scope
--> src/fifth.rs:110:35
|
110 | self.next = node.next.as_deref();
| ^^^^^^^^ help: there is an associated function with a similar name: `as_ref`
|
= note: try using `<*const T>::as_ref()` to get a reference to the type behind the pointer: https://doc.rust-lang.org/std/primitive.pointer.html#method.as_ref
= note: using `<*const T>::as_ref()` on a pointer which is unaligned or points to invalid or uninitialized memory is undefined behavior
error[E0599]: no method named `as_deref_mut` found for raw pointer `*mut fifth::Node<T>` in the current scope
--> src/fifth.rs:121:35
|
121 | self.next = node.next.as_deref_mut();
| ^^^^^^^^^^^^ method not found in `*mut fifth::Node<T>`
|
= note: try using `<*const T>::as_ref()` to get a reference to the type behind the pointer: https://doc.rust-lang.org/std/primitive.pointer.html#method.as_ref
= note: using `<*const T>::as_ref()` on a pointer which is unaligned or points to invalid or uninitialized memory is undefined behavior
Which is correct. I think. We should modify the Iter and IterMut impls to use unsafe methods as_ref() and as_mut() like it made in final code. Because Node.next is a raw pointer now.
Am I right?
And maybe it's worth adding a note about stealing tests for iters?
P.S. I really loved your tutorial. It's wonderful.
The text was updated successfully, but these errors were encountered:
There are unmodified code from stack implementation after the "Let's steal some iterator impls from the stack:"
Compiler yells with:
Which is correct. I think. We should modify the
Iter
andIterMut
impls to use unsafe methodsas_ref()
andas_mut()
like it made in final code. BecauseNode.next
is a raw pointer now.Am I right?
And maybe it's worth adding a note about stealing tests for iters?
P.S. I really loved your tutorial. It's wonderful.
The text was updated successfully, but these errors were encountered: