#Why is vec! putting values twice or in the wrong order

27 messages · Page 1 of 1 (latest)

ivory shard
#

I'm creating a vector with vec!, and some values are applied in the wrong order, others don't get put at all, and some garbage values appear. I can confirm this with the debugger and the produced file.

#

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

brazen pasture
#

you're missing commas

ivory shard
#

bruh

#

im so stupid

#

thanks lol

#

the file is still being read incorrectly though

brazen pasture
#

a HashMap isn't an ordered collection

#

the order of iteration is randomized

#

if that matters

#

I cannot really see what you're doing

ivory shard
#

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

undone jacinth
hexed plank
#

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