4 ms·
Implementing a linked list in Rust is somewhat challenging because of the safety issues that arise. Luckily you don't have to, there's one in the standard libra
by cjg 4y ago
Implementing a linked list in Rust is somewhat challenging because of the safety issues that arise. Luckily you don't have to, there's one in the standard library: https://doc.rust-lang.org/std/collections/struct.LinkedList.html https://doc.rust-lang.org/std/collections/struct.LinkedList....
The equivalent of a generic memcpy is probably something like a .clone() call on a generic type that implements Clone.
- jstimpfle 4y agoThis isn't an intrusively linked list. Probably not the Clone trait but the Copy trait.
- steveklabnik 4y ago> The equivalent of a generic memcpy is probably something like a .clone() call on a generic type that implements Clone. If you type "memcpy" into the documentation search, rustdoc will point you to * https://doc.rust-lang.org/stable/std/primitive.slice.html#method.copy_from_slice https://doc.rust-lang.org/stable/std/primitive.slice.html#me... * https://doc.rust-lang.org/stable/std/intrinsics/fn.copy_nonoverlapping.html https://doc.rust-lang.org/stable/std/intrinsics/fn.copy_nono... (Though it should really point to the reexport at https://doc.rust-lang.org/stable/std/ptr/fn.copy_nonoverlapping.html https://doc.rust-lang.org/stable/std/ptr/fn.copy_nonoverlapp... ) The latter will also mention * https://doc.rust-lang.org/stable/std/ptr/fn.copy.html https://doc.rust-lang.org/stable/std/ptr/fn.copy.html
- fiedzia 4y ago> Implementing a linked list in Rust is somewhat challenging because of the safety issues that arise Implementing linked list in any language that is not memory-safe is challenging because of safety issues. Rust just points it out.