These are chat archives for rust-lang/rust

13th
Sep 2017
Sathya Narrayanan
@sourcepirate
Sep 13 2017 13:21
@all Is there any libraries in rust for generating and applying diff and patch to files ?
Restioson
@Restioson
Sep 13 2017 13:26
heh, you just pinged github.com/all
Which I'm pretty sure is reserved
Is instantiating a struct taxing in rust?
Hans W. Uhlig
@huhlig
Sep 13 2017 13:29
depends on where you allocate
the struct allocation on stack is no more than an alloca call
Restioson
@Restioson
Sep 13 2017 13:29
I'm thinking of switching the delay durations I have from Duration to a u16 of millis (nicer in the config toml) but then I'd have to instantiate it at every callsite
Hans W. Uhlig
@huhlig
Sep 13 2017 13:29
and on heap is basically a malloc call
Denis Lisov
@tanriol
Sep 13 2017 13:29
@huhlig No alloca, just normal stack allocation.
Restioson
@Restioson
Sep 13 2017 13:30
Hm
Hans W. Uhlig
@huhlig
Sep 13 2017 13:30
all true, alloca + initialization
Restioson
@Restioson
Sep 13 2017 13:30
It'd also just be a pain tbh
Denis Lisov
@tanriol
Sep 13 2017 13:30
@huhlig Rust does not (and cannot yet) use alloca
Hans W. Uhlig
@huhlig
Sep 13 2017 13:31
wait what?
ok, now I'm confused. I was told rust already used alloca for dynamic stack allocation
Denis Lisov
@tanriol
Sep 13 2017 13:33
AFAIK, Rust does not yet support dynamic stack allocation. The stack portion a function uses is determined statically.
There's an RFC for that: rust-lang/rfcs#1909
So normally creating a struct on the stack does not require any alloca (but it will still be initialized).
Hans W. Uhlig
@huhlig
Sep 13 2017 13:34
hmm, thanks for the clairification
Denis Lisov
@tanriol
Sep 13 2017 13:35
Actually, it may be never allocated on the stack at all, but placed right into registers if possible.
@Restioson Do you have some impornant reasons to limit them to u16 or just "well, probably longer ones will never be required"?
And what's the problem with Duration in a config file?
stevensonmt
@stevensonmt
Sep 13 2017 16:17
I have what I think should be a simple question but can't find the answer. I want to populate an array from a range. Something like let myarray = [0..10] to have myarray == [0,1,2,3,4,5,6,7,8,9]. Is this not possible?
Restioson
@Restioson
Sep 13 2017 16:22
@stevensonmt you can do this with Vecs (anything with FromIterator, actually afaik) at least: (0..10).collect()
stevensonmt
@stevensonmt
Sep 13 2017 16:22
Yes, but I just wondered since I know the size ahead of time whether an Array would be more appropriate.
Restioson
@Restioson
Sep 13 2017 16:23
Hey, getting some pretty darn strange errors running aarch64 toolchain -- every binary gives me a syntax error... from a compiled binary? Even just cargo triggers this: https://gist.github.com/Restioson/8b56373484d8f7bbb81c3db0ef45c9ad
Denis Lisov
@tanriol
Sep 13 2017 16:32
Are you running it natively or with some kind of emulation?
Restioson
@Restioson
Sep 13 2017 16:33
Via WSL, but shouldn't matter (should it?)
Denis Lisov
@tanriol
Sep 13 2017 16:34
The error messages look as if the system is trying to run them as... shell scripts, probably -- while they are compiled files...
Restioson
@Restioson
Sep 13 2017 16:34
Hm... works for other toolchain versions?
Denis Lisov
@tanriol
Sep 13 2017 16:46
...IIUC, "nightly-aarch64" is the toolchain compiled for an AARCH64 host. Do you really need this one?
Restioson
@Restioson
Sep 13 2017 16:46
For the aarch64?
derp
super derp
argh
I wanted rustup target i think
Denis Lisov
@tanriol
Sep 13 2017 16:47
rustup component, probably
Or target, yes.
Restioson
@Restioson
Sep 13 2017 16:48
wow, tysm
Now, let me try target x.x