LiveSplit / asr

Helper crate to write auto splitters for LiveSplit One's auto splitting runtime.
https://livesplit.org/asr/asr
Apache License 2.0
10 stars 10 forks source link

Allow to read memory slices of unknown size at compile time #85

Closed Jujstme closed 8 months ago

CryZe commented 8 months ago

Mmh, I wonder if it would be better to provide the vector as a vec: &mut Vec<T>, where it then is able to reuse the allocation at least.

Jujstme commented 8 months ago

I don't follow. Vec's ownership just gets moved.

EDIT: oh, I understand now.

Jujstme commented 8 months ago

Mmh, I wonder if it would be better to provide the vector as a vec: &mut Vec<T>, where it then is able to reuse the allocation at least.

It's possible but it means the user will be limited by the capacity() provided when instancing the Vec. I can probably provide both methods.

Jujstme commented 8 months ago

read_into_vec() has now been updated in order to use reserve(), this way the Vec is guaranteed to have the capacity needed to read from memory the amount of data specified in the method call