These are chat archives for rust-lang/rust

6th
Oct 2017
Kieran
@kieraneglin
Oct 06 2017 02:02
@tanriol Yeah, it's definitely an uncommon use case. I kind of expected the ability to go to and from arbitrary bases
Kieran
@kieraneglin
Oct 06 2017 02:37
Related, is there a version of nth that doesn't consume the iterator?
Also, why on earth is that the behavior of nth. I just want to get a single character from a str
CrLF0710
@crlf0710
Oct 06 2017 02:43
Well, in your case i believe you are not dealing with full-range Unicode string at all. It'll be much easier if you just use Vec<u8> to generate those you want, and optionally convert it to a String afterwise.
CrLF0710
@crlf0710
Oct 06 2017 02:49

Related, is there a version of nth that doesn't consume the iterator?

You can skip and peek... if that's what you want

red75prime
@red75prime
Oct 06 2017 03:12
@kieraneglin, nth doesn't consume iterator (consuming it would be nth(self, n: usize)), it advances iterator. But iterators cannot be restarted. If you need random access to string characters, it's probably better to convert it into array of chars.
samoylovfp
@samoylovfp
Oct 06 2017 12:50
Hi! I was explaining trait objects to a friend and when rereading the chapter from the second book I found this sentence, which I didn't understand. Can someone please clarify? However, trait objects are different from objects in other languages because we can't add data to a trait object. https://doc.rust-lang.org/book/second-edition/ch17-02-trait-objects.html
David Harvey-Macaulay
@alteous
Oct 06 2017 12:51
@samoylovfp It means you can only access functions from a trait object.
I assume the 'in other languages...' part is referring to abstract classes in Java, for example.
samoylovfp
@samoylovfp
Oct 06 2017 12:53
I see
Thanks for explaining! Awesome docs otherwise, thanks for them!
David Harvey-Macaulay
@alteous
Oct 06 2017 12:54
:+1:
Steve Klabnik
@steveklabnik
Oct 06 2017 13:18
:D
Christian Bourjau
@cbourjau
Oct 06 2017 14:24
Hi there! I have a question about "streams". My problem is as follows. I want to read many individual objects from disc. They are compressed, so I multithread that part into N threads. I then send those objects down a channel using futures::sync::mpsc. My "single consumer" is in the next() function of an iterator. Thats the first side of the issue. But now I want to process these objects. This processing is also CPU intensive, but might not scale 1:1 to the IO threads. So I wonder now how I could split up whatever comes out of my "single consumer iterator" into M threads? (Sorry for the sloppy language, its all new to me :D)
Michal 'vorner' Vaner
@vorner
Oct 06 2017 14:28
@cbourjau You could look into the rayon crate, it might contain something useful for that use case. Or something like cpu pool.
Denis Lisov
@tanriol
Oct 06 2017 14:32
@cbourjau I'd look into futures_cpupool
Christian Bourjau
@cbourjau
Oct 06 2017 14:40
Thanks I will look into those! My worry is a bit that the IO thread may churn out objects faster than I can process them. Thats why I joint the two parts of my problem through an iterator. But I am not at all sure that this is the way to go. Either way, I'm looking into impl'ing rayon's ParallelIterator now. Maybe thats a easy way out?
Antonin Carette
@k0pernicus
Oct 06 2017 19:42
Hello
Laurențiu Nicola
@lnicola
Oct 06 2017 19:43
Hi
Antonin Carette
@k0pernicus
Oct 06 2017 19:43
I am running ./x.py test --stage 1 src/test/debuginfo on my laptop in order to valid the tests for a PR
Unfortunately, I got some troubles running those tests (98 tests/108 failed), and I’ve got the same error 98 times:
…
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py", line 155, in sub
    return _compile(pattern, flags).sub(repl, string, count)
TypeError: expected string or buffer
Is anyone here has got this stack trace when running those tests please?
Thanks in advance
Laurențiu Nicola
@lnicola
Oct 06 2017 19:47
Sounds like a helper script has issue parsing the output of a test
Antonin Carette
@k0pernicus
Oct 06 2017 19:48
It’s me ;-)
Laurențiu Nicola
@lnicola
Oct 06 2017 19:48
Yeah :D
Maybe that LLDB error is relevant?
Antonin Carette
@k0pernicus
Oct 06 2017 19:50
Yep, it’s weird…
Also, I didn’t « touch » the code of the files those scripts are testing
I thought I made an error in my test configuration, or something like that...
Laurențiu Nicola
@lnicola
Oct 06 2017 19:53
it says
    return re.sub("\s+", " ", s)
and I can reproduce that with
>>> import re
>>> re.sub("\s+", " ", None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/re.py", line 155, in sub
    return _compile(pattern, flags).sub(repl, string, count)
TypeError: expected string or buffer
so s might be None
Antonin Carette
@k0pernicus
Oct 06 2017 19:54
I agree
Laurențiu Nicola
@lnicola
Oct 06 2017 19:54
but s might be res.GetOutput, that is the output of a test
(or whatever it's trying to run)
Antonin Carette
@k0pernicus
Oct 06 2017 19:55
Right - I will inspect the script
Thanks ;-)
Laurențiu Nicola
@lnicola
Oct 06 2017 19:55
thread '[debuginfo-lldb] debuginfo/self-in-generic-default-method.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:2617:8
is that yours?
Antonin Carette
@k0pernicus
Oct 06 2017 19:55
Nop
Laurențiu Nicola
@lnicola
Oct 06 2017 19:58
runtest.rs doesn't have 2600 lines :worried:
Antonin Carette
@k0pernicus
Oct 06 2017 19:58
Yep
2445 for me actually...
:worried:
Laurențiu Nicola
@lnicola
Oct 06 2017 20:01
do you have lldb?
Antonin Carette
@k0pernicus
Oct 06 2017 20:01
Yes
Laurențiu Nicola
@lnicola
Oct 06 2017 20:02
can you run a single test?
and maybe run the test runner under strace?
erm.. dtrace
whatever it's called
dtruss -f
umm, not like that
Antonin Carette
@k0pernicus
Oct 06 2017 20:06
Yeah sorry, I failed...
Laurențiu Nicola
@lnicola
Oct 06 2017 20:06
dtruss -f ./x.py whatever-you-have-to-type-here-to-run-a-single-test
and ask Google about the security thing
last time I tried to work on a Mac I stared 5 minutes at the power connector because I didn't know which way to plug it in
(MagSafe)