Implement serialize/deserialize for std::iter::Rev?

The std::tier::Rev struct currently does not implement the serialize and deserialize traits. Would it be possible to fix that?

If you're talking about the serde traits, that has to be fixed by serde, not std.

7 Likes

It doesn't make sense to serialize or deserialize any iterator in Rust.

Unlike C++, Rust's iterators don't describe a collection. They only represent a temporary state of a single-use-only stream of items. They're the i in for(int i=0; i < 10; i++) collection[i].

You should be (de)serializing the collection instead of state of iteration of a collection.

4 Likes

It could. Serializing a non-borrowing iterator, as part of serializing the state of a long-running computation that might be interrupted, is a coherent thing to do, though certainly a narrow situation.

3 Likes

Rev<Range<{integer}>> is one I thought of that makes sense (also a niche desire).

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.