Skip to content

Add a way to reset MemWriter #16167

Closed
Closed
@SiegeLord

Description

@SiegeLord

MemWriter recently lost its ability to seek due to speed concerns, which removed any way of resetting/truncating it (i.e. seeking backwards). Could this be added? A possible API/implementation would be:

// Does nothing if new_len is greater than current length
pub fn truncate(&mut self, new_len: uint) { self.buf.truncate(new_len); }

Alternatively, perhaps a new constructor could be added which would wrap an existing Vec which would allow me to do this:

let writer = MemWriter::new();
let mut vec = writer.unwrap();
vec.truncate(new_len);
let writer = MemWriter::wrap(vec);

@erickt, I recall talking to you about this on IRC, so you may have some thoughts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions