These are chat archives for rust-lang/rust

9th
Feb 2018
Kelly Thomas Kline
@kellytk
Feb 09 2018 01:57
How should a struct ref be used to generate a copy of the struct instance with ownership?
Ashley Mannix
@KodrAus
Feb 09 2018 01:59
@kellytk You can use the .clone() method for this
Or .to_owned() if you've got a borrowed string or slice
Kelly Thomas Kline
@kellytk
Feb 09 2018 02:02
*strct.clone() is generating the error "cannot move out of borrowed content"
The return type is Strct
Ashley Mannix
@KodrAus
Feb 09 2018 02:04
Are you able to just call strct.clone(), without the dereference?
Kelly Thomas Kline
@kellytk
Feb 09 2018 02:05
If I don't deref, I get an error that it expected struct, found ref
Kelly Thomas Kline
@kellytk
Feb 09 2018 02:10
Thanks @KodrAus
Ashley Mannix
@KodrAus
Feb 09 2018 02:11
@kellytk Did that sort out your problem?
Kelly Thomas Kline
@kellytk
Feb 09 2018 02:11
Yes :-D
Ashley Mannix
@KodrAus
Feb 09 2018 02:12
That's good :)
David Harvey-Macaulay
@alteous
Feb 09 2018 19:49
Is it possible to print an info message in build.rs?
David Harvey-Macaulay
@alteous
Feb 09 2018 19:55
One can print a warning with println!("cargo:warning=foo") which outputs warning: foo but I just want a plain message,
Alkis Evlogimenos
@alkis
Feb 09 2018 20:50
what's the right way to rename a crate on crates.io
Steve Klabnik
@steveklabnik
Feb 09 2018 20:50
change the name, upload as the new name
Alkis Evlogimenos
@alkis
Feb 09 2018 20:50
and the old crate?
Steve Klabnik
@steveklabnik
Feb 09 2018 20:50
change its readme to point to the new version, release it, never touch it again
Alkis Evlogimenos
@alkis
Feb 09 2018 20:51
cheers!
Steve Klabnik
@steveklabnik
Feb 09 2018 20:51
no problem :)
basically, crates.io is as append-only as legality allows
Robert
@PurityLake
Feb 09 2018 20:54
I've tried getting into Rust a few times now and either stuff has come up or my understanding of moving trips me up a lot, now even C++ supports moving (not the same semantics as Rust but similar in idea). I'm giving it another go this weekend anyway so wish me luck and maybe I'll become a
rustacean
Steve Klabnik
@steveklabnik
Feb 09 2018 20:54
good luck! :)
Alkis Evlogimenos
@alkis
Feb 09 2018 20:55
@steveklabnik what happens with the README.md from the github repo once the repo is renamed?
Steve Klabnik
@steveklabnik
Feb 09 2018 20:55
in what sense
the readme there came from the github repo (I think publish does this automatically?)
Steve Klabnik
@steveklabnik
Feb 09 2018 20:56
oh, i think i see what you mean. that README isn't pulled from github
it came from the crate itself, when you published it
Alkis Evlogimenos
@alkis
Feb 09 2018 20:56
ok so I locally edit the README and push 0.2.1 saying this is deprecated here's a link to the new crate?
Steve Klabnik
@steveklabnik
Feb 09 2018 20:57
yeah
or even 0.3, whatever :)
Alkis Evlogimenos
@alkis
Feb 09 2018 20:57
sure, I think version doesn't matter at this point
bikeshedding: how about superslice as the name of the new crate? :-)
Steve Klabnik
@steveklabnik
Feb 09 2018 20:57
totally
i gotta run, good luck!
Alkis Evlogimenos
@alkis
Feb 09 2018 20:58
kk
Kelly Thomas Kline
@kellytk
Feb 09 2018 22:03
What is the most succinct means of copying a Vec from another Vec, beginning at index 1 and ending at, at most, index 4?
David Harvey-Macaulay
@alteous
Feb 09 2018 22:49
@kellytk Perhaps with an iterator, i.e. dst.extend(src.iter().skip(1).take(3))?
Kelly Thomas Kline
@kellytk
Feb 09 2018 23:16
Thanks @alteous. That elegant line replaced 12 tedious others and introduced me to several useful API features
David Harvey-Macaulay
@alteous
Feb 09 2018 23:17
My pleasure!
Sean Perry
@shaleh
Feb 09 2018 23:32
How does one determine which version of nightly clippy works with? Short of just randomly walking backwards looking for one
If you know it is 1 and 3 you can also use nth @kellytk
src.iter().nth(4)
Handy for when you just need one item.
Kelly Thomas Kline
@kellytk
Feb 09 2018 23:36
Thanks @shaleh. Out of curiosity, in the case of a single element, why would you use that rather than indexing into the vec?
Patrick Elsen
@xfbs
Feb 09 2018 23:37
nth(x) returns None if the element doesn't exist, whereas vec[x] panics
Kelly Thomas Kline
@kellytk
Feb 09 2018 23:37
Oh, that is handy
Sean Perry
@shaleh
Feb 09 2018 23:48
I might not have a Vec. nth works on an iterator of any base.
Get the nth thing from a stream of things