« first day (1375 days earlier)      last day (2115 days later) » 

9:02 AM
@Boiethios github.com/rust-lang/rust/blob/… Have a go at fixing it? ;)
 
9:19 AM
@PeterHall Huh, I understand nothing at compiler stuff... I let you do it
 
@Boiethios Maybe another day ;)
 
9:53 AM
@Boiethios But I am still not convinced that it is a bug
When you define a struct with a HRTB in its definition, it means that the struct is defined given some unknown lifetime. Then you define the Drop impl, again for some unknown lifetime. What makes them the same lifetimes?
 
10:10 AM
@PeterHall hrtb?
 
@orlp Higher ranked trait bounds.
 
what exactly is that?
 
ah I'm not familiar with that
 
You mostly don't need it
just once in a while...
 
10:16 AM
@PeterHall Why does it works for the other traits?
 
@Boiethios You mean why just drop?
 
@PeterHall Yep
 
Because Drop has a special check to make sure you didn't accidentally define it for only a subset of instances
If you have:

struct Foo<T>(T);

You can't define Drop for only where T: Debug.
 
Ok I understand now
 
Unless the original struct has that constraint
 
10:19 AM
Sure
 
Usually when you have <'a> in a bound, it is universally quantified. That is, it is defined for ALL possible `a
When you use HRTB, for<'a>, you are existentially quantifying 'a
which means the definition holds for SOME unknown 'a
 
Why the compiler developers (who are smart guys I guess) say that this is a bug then? I guess they have some idea about how to permit Drop + HRTB
 
I think it can still be fixed
But the behaviour is compatible with documentation
It's more of a bug in the design than a bug in the implementation
 
@PeterHall Oh, I had this in mind, indeed. I guessed that the issue is still unsolved because it will one day thanks to chalk.
 
@Boiethios Chalk is the new NLL :P
 
10:37 AM
@PeterHall Hehe, exactly :P NLL is still not here, tho
fn main() {
    let mut vec = vec![1, 2, 3];
    vec.push(vec.len());
}
Does not compile out of the box
 
10:48 AM
@Boiethios Indeed not.
 
 
3 hours later…
1:50 PM
I enjoy my comment sequence here stackoverflow.com/a/51443397/155423
 
2:16 PM
Hm. Yeah. Also, necro'ing a 2-year-old question that was last edited... over a year ago?
Never mind that the question was never very good, and seems to include some misconceptions about how time and threads work.
 
Why doesn't &str implement IntoIterator<Item=char, IntoIter=Chars>?
 
@Boiethios I think it'd be unclear whether it'd iterate over bytes or characters
 
Hum, seems legit
 
2:33 PM
You can actually get the iterator structures using .bytes or .chars. It's a little odd to me that it doesn't implement the trait for both iterable types and let the typechecker take care of it.
 
@Zarenor Well, it removes all interest to implement twice IntoIterator: the caller would specify the Iterator he wants when he calls a function bounded to IntoIterator.
 
3:03 PM
Anyone have some feedback on the approach I'm taking here: github.com/peterjoel/lazy_concat
It's very rough still. I've been experimenting with it.
Essentially lets you create a lazy concatentation of str or slices, and it only allocates the full result when necessary.
So you can iterate through chars or slice elements
And if you take a slice, it will allocate just enough so that the slice works
I'm partly wondering if it's useful enough to put into a crate. Reason being, it was originally something I needed for String, then I generalised it to Vec<T> and then finally didn't need it after all...
 
3:20 PM
eh
I'm worried about get_slice
 
@orlp The syntax? or something else?
 
that might very quickly become very inefficient
where instead of avoiding allocations
you're now allocating on every get_slice request
 
Well, once a portion has been normalized, it won't happen again
so only if you are getting slices that you haven't asked for before
 
eh what about this?
 
You can also just normalize() the whole thing once
 
3:22 PM
for i in 0..100 { lazy_vec.get_slice(0, Some(i)); }
also don't use camelCase variable names :P
 
@orlp heh I may have done that :)
@orlp The fragments that are sliced together are likely to be bigger than one character. But perhaps it should just fully normalize when you take a slice
There are possibly cases when you wouldn't want that, I imagine
 
@PeterHall only necessary when the slice crosses a string boundary
 
@orlp That's what it does now
 
but does it then replace the old strings
with the singular joined string?
so that it doesn't repeatedly allocate?
 
It doesn't repeatedly allocate
It would be really difficult to write it any other way. If it only temporarily allocated then the lifetimes would be impossible to manage
 
3:48 PM
Internally, for Strings, it has a single owned String root, and various fragments of String and &str in a Vec. When it normalizes, it extends the root String and drains the used fragments from the vec.
 
4:06 PM
@PeterHall Any reason you couldn't do that without the "root"?
i.e., only merge slices and strings when the requested slice actually crosses the boundary
 
@trentcl What do you mean?
It currently only merges onto root what is needed for the requested slice
Root is the owned part, from which slices are taken
 
@PeterHall But if you have a megabyte of 'static data, followed by five Strings, and you request a slice that spans the last two fragments
 
Oh I see
The data is all stored in Cows
so it could technically collapse those two fragments into one Cow::Owned
but...
depending on how long you wanted that slice to last, it might get tricky if you then request a slice that overlaps that fragment and the previous
 
@PeterHall I think you already have that problem though?
because get_slice takes &mut self
 
@trentcl Yes, so a solution would be to store root in a RefCell
 
4:17 PM
ahh
 
(assuming you're saying what I think you're saying)
 
hmm
 
posted on July 20, 2018

The Rust team is happy to announce a new version of Rust, 1.27.2. Rust is a systems programming language focused on safety, speed, and concurrency. If you have a previous version of Rust installed via rustup, getting Rust 1.27.2 is as easy as: $ rustup update stable If you don’t have it already, you can get rustup from the appropriate page on our website, and check out the detailed rele

4
 
4:36 PM
@trentcl So I was actually also creating an append-only cell type. It doesn't let you borrow mutably, and existing data will always live for the full life of the wrapper. The only mutable operation is appending, which is guaranteed to not affect any existing borrows. It's nice because you can keep borrowing slices from it, and only have to worry about the lifetime of the wrapper, and no possible panics
 
sounds like an arena
 
Possibly, but less general
It assumes that it owns a vec
 
@PeterHall I'm afraid I am about to throw a wrench in the works but... appending to a Vec invalidates existing slices because it might have to reallocate
 
@trentcl True!
So.. that means I'd have to limit the lifetime of each slice up until the next time it is normalized
 
shades of streaming iterators
 
4:40 PM
Which actually is already enforced by the fact that get_slice() takes &mut self
 
right, or a RefMut
so, either you've reimplemented Vec<T> or RefCell<Vec<T>> ;-)
 
There should be a resize_in_place(self) -> Result<Vec, Vec> method on Vec
 
Ok... but you couldn't rely on that for static type checking
 
@trentcl would Err be resized or not?
 
@Shepmaster I would say not... although
maybe a &self-taking function would work?
 
4:44 PM
@PeterHall it all feels too dynamic for static checks to start with... like, it's based on Vec's impl and how much data you push in
 
I wonder... could a theoretical extend_in_place() take &self safely?
 
@trentcl that's both terrible and seemingly completely accurate
 
I originally wrote LazyConcat with every method taking self. Just to see.
I wasn't very wieldy
 
reserve_in_place(&self, additional: usize) -> Result<(), ()>
return value to be bikeshedded
 
would need to only grow in size
 
4:46 PM
Feels wrong. But I can't see an actual problem
The problem is how a reasonable program should recover from an Err
The whole point presumably is to avoid invalidating a bunch of slices. So now what?
 
@PeterHall true
 
4:59 PM
What we need is some sort of process that runs all the time and looks after this sort of thing ;)
 
brilliant
but for real though, can you have a MySlice(Arc<Vec<T>>, start, len)
 
I know. I'm thinking we could get rid of a lot of the annoying lifetime stuff that way too
 
well, Rc<RefCell<Vec<T>>>
 
@Shepmaster Yes. Why not
I'm just not sure it's that useful. It has all the same problems as the above discussion, no?
 
I meant that more as a "would this work for your situation", not "is it possible"
 
5:02 PM
perhaps
But actually I think having get_slice take &mut self is quite a good thing
There's not much point in having two methods - one &must self and one &self - then checking at runtime which one to use.
 
5:14 PM
I'm thinking about something like Vec<RefCell<Cow<B>>>
the RefCells are inside the Vec so that you don't have to borrow the whole thing to merge two of them -- you can just append one to the other and replace the second one with Cow::Borrowed("")
or equivalent
however you still need to borrow the whole thing to append new fragments... so maybe you need an extra RefCell layer anyway.
 
doesn't entirely solve the problem of not invalidating existing slices
 
no
But if there were an Rc analog that maintained separate pointers to data and refcount...
 
Unless slices are not slices, but something like (&LazyConcat, usize, usize)
 
(surely this exists in a crate somewhere)
 
You could do quite a lot with that. But every so often you'd have to clone data to work with some API, and in general it would be slower - and that would be hard to reason about
 
5:20 PM
you could have Vec<Rc<Cow<B>>> and get_slice could return Rc<B>
yeah I'm going to stop now
 
@trentcl It couldn't because the slice could span multiple fragments
@trentcl and yeah, I need to leave now. So that's a convenient point :)
 
@PeterHall You could make_mut one of the Rcs and merge the slices without affecting previously returned Rcs. But yes, that's where the cloning (possibly) comes in
 
5:37 PM
@E_net4 Box<Box<Box<Goose>>>
Is that a cultural reference that translates?
 
5:52 PM
so, how long would it take to process 30M DNS requests
-4
Q: How to send 30 million concurrent DNS requests fast?

MortyAndFamI want to send a DNS query to 30 million strings and I have hit a dead end. Initially the machine was crashing due to having too many threads in queue (or that's what I made out of it) which I countered with a conditional break. Now the process, while it doesn't crash the computer, takes fore...

I kind of think that, at that point, you just see if you can download the entire DNS database from these servers somehow.
 
@Shepmaster shrug
 
@Shepmaster it seems that those bottlenecks I haven't hit yet. Given enough ram I could do this in 2 hours but I have 60gb only (I know, I shouldn't need RAM at all) — MortyAndFam 1 min ago
Duck, Duck, Gray Duck (also called Duck, Duck, Goose or Daisy in the Dell) is a traditional children's game often first learned in pre-school or kindergarten. The game may be later adapted on the playground for early elementary students. The object of this game is to walk in a circle, tapping on each player's head until one is finally chosen and he or she must chase the picker to avoid becoming the next picker. Originating from Sweden, the game was originally called "Anka Anka Grå Anka", which translated means “duck duck gray duck” == Basic concept == A group of players sit in a circle, facing...
 
Hmm, I would've never gotten that by name.
@E_net4 I can not change consume_func, so I prefer to handle it as black box. — user1244932 38 secs ago
:why:
 
6:21 PM
It's a shame they cannot change it
fn consume_func<F: Foo + ?Sized>(b: Box<Box<F>>) {
    unimplemented!();
}
 
6:45 PM
Why cannot I write std::io::Result::Ok(2)?
 
fn main() {
    let _ = std::io::Result::Ok(2);
}
 
 
1 hour later…
8:25 PM
> note: did you mean variant::Ok?
that's so very wrong
 
8:46 PM
@Boiethios Pretty sure this is going to be one of those "type aliases are kind of strange" issues
 
 
3 hours later…
11:39 PM
love me some T y E P s
@Shepmaster That is ridiculous, what the hell's happening there?
 

« first day (1375 days earlier)      last day (2115 days later) »