These are chat archives for rust-lang/rust

16th
Apr 2019
Ayush Prashar
@ayushprashar
Apr 16 04:55
Hey guys,
I've been developing in Rust for a while now and have been referencing Servo and official rust book in order to write standardized code. But are there any other documentations we can follow in order to ensure I'm following the best practices for development in Rust.
Edvin Malinovskis
@nCrazed
Apr 16 07:26
ayushprashar: are you using clippy?
toxicafunk
@toxicafunk
Apr 16 07:42
and if u aren't, what r u waiting for!!! :D
Ayush Prashar
@ayushprashar
Apr 16 07:43
I am
but Not just for warnings
i use cargo fmt, clippy, and tarpaulin
to keep it straight
i just want to verify that I'm not missing any standards to follow
SEGFAULT
@IGBC
Apr 16 16:15
Hi I am having a problem scoping traits
I have the struct tokio_xmpp::Client and it implements Stream from futures::stream
I added use futures::stream::Stream; to my code but the compiler reports: use of undeclared type or module futures
what did I do wrong?
Akos Vandra
@axos88
Apr 16 17:08
Hi! If I run exec( /proc/self/exe, /proc/self/cmdline), would that correctly free up resources, or would I need to do a fork & exec to do that? My application loads some of its config only during boot and when some of those config files change, I'd like the app to be able to restart itself.
This is an embedded system, so no fancy stuff like supervisors are available, or desired
David Holroyd
@dholroyd
Apr 16 21:04
Hi! I am after a queue-ish data structure that,
  • can have items added onto the tail, and removed (in batches, possibly via drain()) from the head
  • stores items contiguously (provides a single slice view over the contents - I think this rules out VecDeque)
  • amortises the cost of removals across multiple operations (I think this rules out Vec, which would shuffle entries 'to the left' every on removal)
is there a crate for this / is there an accepted term for this thing that I could search for?
I had started to cut'n'paste something together out of bits of VecDeque code, but then I realised that I might not be able to use RawVec on stable, so decided better to ask! :D
David Holroyd
@dholroyd
Apr 16 21:26
I can try and continue that but using RawVec from the allocator_api crate I just spotted, but would be even better if ContiguousQueue already exists!
Akos Vandra
@axos88
Apr 16 21:36
Is there a (standard) data structure similar to Either<>, but allowing Both to be set (but not neither)?
So basically I'm looking for Either<A, Either<B, (A,B)>>
David Holroyd
@dholroyd
Apr 16 21:39
(answering my own earlier question, looks like slice-deque could work)
Ichoran
@Ichoran
Apr 16 21:43
Yeah, I'd just do Either<(A, B>, Either<A, B>>
I tend to make a lot of new enums in my code, though, so I'd probably just enum Or <A, B> { One(A), Two(B), Both(A, B) }
Denis Lisov
@tanriol
Apr 16 22:10
@IGBC Do you have a dependency on futures? Is your crate on edition 2018 or, if not, do you have the extern crate futures; in the crate root?
@axos88 You may need to deal with open files (file descriptors) as exec will not cleanup these unless they have been marked for close-on-exec.
Akos Vandra
@axos88
Apr 16 23:57
@tanriol if I fork(), and then in one branch exec, in the other one exit the process, wouldn't that clean up the files?