#Why is vec! putting values twice or in the wrong order
27 messages · Page 1 of 1 (latest)
I also have code to read the file and convert it to be readable and it produces a different output every time with the same file..
Am I doing something horribly wrong here?
I'm using file.write_all and file.read_to_end
When I println! the vector, it shows the same incorrect values as the ones in the file
you're missing commas
bruh
im so stupid
thanks lol
the file is still being read incorrectly though
a HashMap isn't an ordered collection
A hash map implemented with quadratic probing and SIMD lookup.
the order of iteration is randomized
if that matters
I cannot really see what you're doing
I'm iterating over the file's length
wait
I'm also iterating over the map
And then comparing the values of the current byte from read_data and the current value from the map
if you want a map that preserves the original insertion order, use https://docs.rs/indexmap/
if you want a stable order and 'sorted' will do, use https://doc.rust-lang.org/std/collections/struct.BTreeMap.html
by the way @ivory shard, you would’ve spotted the missing comma much more quickly if you had rustfmt set up to run on save
you can do that by enable format on save in the vscode preferences
this worked