Why is `Copy` not implemented for `std::io::Cursor`?

⚓ Rust    📅 2025-07-10    👤 surdeus    👁️ 4      

surdeus

The title says most of it, but is there a specific reason why there is no impl<T: Copy> Copy for Cursor<T>? Taking Cursor<&[u8]> as an example, it semantically makes total sense to cheaply copy this type around, e.g. if i have functions that read from the cursor's position but the caller still wants to continue from that position.

The best reason I can think of as to why Copy shouldn't be implemented on the type is for expanding the type with some non-Copy fields further down the road, but then the idea of a "Cursor" doesn't feel like it should be too heavy anyway.

3 posts - 3 participants

Read full topic

🏷️ rust_feed