These are chat archives for rust-lang/rust

19th
Nov 2017
Fra ns
@snarf95_twitter
Nov 19 2017 19:38
crate arrayvec is giving me problems with really big sizes... is there a reason for this?
Alexander Ivanov
@alehander42
Nov 19 2017 19:44
if it's fixed size and allocated statically you might need special flags for compiling if more than 2gb
at least that happened to me with static arrays in other lang
Fra ns
@snarf95_twitter
Nov 19 2017 20:04
well my size is statically known
it won't allow my 196.608 elements ..
shame :/
in total we're talking about ~6 mb of data
Jonas Platte
@jplatte
Nov 19 2017 20:08
@snarf95_twitter I don't know how big exactly the stack is by default, but I'm pretty sure that even if it's possible to put 6MB of data on it, that would be a pretty bad idea
Alexander Ivanov
@alehander42
Nov 19 2017 20:09
bluss/arrayvec#2
Fra ns
@snarf95_twitter
Nov 19 2017 20:10
true enough but I actually though it would still be put on the heap... maybe I misunderstood the concept of arrayvec
Alexander Ivanov
@alehander42
Nov 19 2017 20:10
yep there are limitations, probably 2mb stack
Fra ns
@snarf95_twitter
Nov 19 2017 20:10
guess I'm just gonna use Vec then
Alexander Ivanov
@alehander42
Nov 19 2017 20:11
I am not a rust guy just guessing :smile:
Fra ns
@snarf95_twitter
Nov 19 2017 20:11
trying to micro optimize basically, I don't wan't it to be possible to grow
Alexander Ivanov
@alehander42
Nov 19 2017 20:11
you can use several
Aleksey Kladov
@matklad
Nov 19 2017 20:11
@snarf95_twitter you could use Box<[T]> then, it won't be more efficient then Vec really
(provided that you use Vec::with_capacity(196608))
Fra ns
@snarf95_twitter
Nov 19 2017 20:12
yeah I do
okay, then I'm just going to stick with Vec
Fra ns
@snarf95_twitter
Nov 19 2017 20:45
why am I forced to use usize for array indices etc.
Ilya Bogdanov
@vitvakatu
Nov 19 2017 20:49
Because negative indices are non-sense
Fra ns
@snarf95_twitter
Nov 19 2017 20:51
true but in this case im making sure that is not the case... the result of forcing usize is that I have to cast all the time...
Denis Lisov
@tanriol
Nov 19 2017 20:52
@snarf95_twitter Why do you have to use something other than usize for the variables you index with?
Fra ns
@snarf95_twitter
Nov 19 2017 20:54
well in this case I'm iterating of a 3d grid and I need to evaluate neighbors but also respect the bounds of the grid
Denis Lisov
@tanriol
Nov 19 2017 20:55
I'd just use usizes for all indices and dimensions of the grid.
Fra ns
@snarf95_twitter
Nov 19 2017 20:56
hmm yea... I could do that... but then my other code involving the indices would have to be casted from usize to u8 etc.