These are chat archives for rust-lang/rust

8th
Jan 2018
Moggers
@Moggers
Jan 08 2018 04:44
any recommendations on a quad tree implementation for collision detection?
Moggers
@Moggers
Jan 08 2018 13:11
the way borrows in an if let extend into the else really annoy me
Denis Lisov
@tanriol
Jan 08 2018 13:11
They will not when NLL comes to stable, AFAIK.
Moggers
@Moggers
Jan 08 2018 13:12
oh, I'm on nightly
is there a feature I can enable to change this behaviour?
Denis Lisov
@tanriol
Jan 08 2018 13:12
You can try #![feature(nll)], but I don't know its current state.
Michal 'vorner' Vaner
@vorner
Jan 08 2018 13:13
I think feature(nll) is supposed to work now.
Moggers
@Moggers
Jan 08 2018 13:13
seems to work
cool \o/ thanks
Michal 'vorner' Vaner
@vorner
Jan 08 2018 13:13
With an occasional bug
Moggers
@Moggers
Jan 08 2018 13:13
uhoh
error: internal compiler error: unresolved type in dtorck
Michal 'vorner' Vaner
@vorner
Jan 08 2018 13:13
Are you by any chance using flat_map?
Moggers
@Moggers
Jan 08 2018 13:14
I dont think I am
I guess one of my dependencies might be?
Michal 'vorner' Vaner
@vorner
Jan 08 2018 13:14
Your dependency shouldn't be using nll. rust-lang/rust#47022
Moggers
@Moggers
Jan 08 2018 13:15
oh its a known issue?
Sherab Giovannini
@Shaddy
Jan 08 2018 16:20
hi, I'm having a weird behaviour (or just weird for my understanding). I have something like this
let instance = Struct::new();
let whatever = Takes::new(&instance.internal_object);
let another = Holds::new(&instance);
at some point, Takes::new is holding a reference of an internal_object, with its lifetime connected with another internal references, my problem is that even if I have ownership of "instance" in this scope, whenever the reference gets drestroyed (after whatever gets out of use) Drop is called for instance.internal_object
how is it possible to call drop while I still have the original instance and it is only a reference?
Denis Lisov
@tanriol
Jan 08 2018 16:22
Could you make a playground example?
Sherab Giovannini
@Shaddy
Jan 08 2018 16:23
I would try, but its really hard to replicate the behaviour. Let me try
Denis Lisov
@tanriol
Jan 08 2018 16:24
Your project is not public, is it?
Hayden Pope
@TheStilbruch
Jan 08 2018 16:31

Hey, I’m struggling with a error that I dont really understand. Im getting

error[E0507]: cannot move out of borrowed content

but my method takes &self so I don’t really understand how its moving it. Im a bit of a newbie with rust and systems programming in general so I apologize if this is a dumb question

Steve Klabnik
@steveklabnik
Jan 08 2018 16:32
it's not!
the &self is why it's borrowed content
as for what's moving it, well, whats the rest of the error?
Sherab Giovannini
@Shaddy
Jan 08 2018 16:32
@tanriol is not :(
but im trying to replicate the behaviour
Hayden Pope
@TheStilbruch
Jan 08 2018 16:36
@steveklabnik Here’s the rest of it
   |
15 |             let result: String = self.base_strand.into_iter().map(|c| match c {
   |                                  ^^^^ cannot move out of borrowed content
Steve Klabnik
@steveklabnik
Jan 08 2018 16:36
so!
fn into_iter(self)
so, you have self borrowed thanks to the type of your method, but you're trying to move it becasue you're calling into_iter() on it
does that make sense?
Hayden Pope
@TheStilbruch
Jan 08 2018 16:38
Oh that makes sense. Just a little hard to determine from the error message. So would iter() be the way to go?
Steve Klabnik
@steveklabnik
Jan 08 2018 16:38
if it works, then yes
it's hard to say if it works or not based on the contents of the map call
Hayden Pope
@TheStilbruch
Jan 08 2018 16:39
Yeah I just got it to work. In the past I have written alot in Scala, so I’m always trying to use iterators and maps and stuff but it doesn’t seem like they play very nice with Rust
Or at least they are more compicated than in Scala
Steve Klabnik
@steveklabnik
Jan 08 2018 16:40
yeah, ownership means there's three ways of doing things
Sherab Giovannini
@Shaddy
Jan 08 2018 17:25
well, I think its better to just put a breakpoint and see what happens
is it possible to compile an int3?
with asm feature
Sherab Giovannini
@Shaddy
Jan 08 2018 17:40
found the problem, obviously is not rust related :), a second object was created internally at some part to simplify an api, and OS doesn't like it :D
Hayden Pope
@TheStilbruch
Jan 08 2018 17:50

What does

&'a str

mean in rust? I can’t seem to find it on google, probably because of the weird characterrs

Alexandre Bury
@gyscos
Jan 08 2018 17:50
It means a &str that only lives as long as 'a
('a is the name of the lifetime)
Hayden Pope
@TheStilbruch
Jan 08 2018 17:55
Hmm and how do I name lifetimes
Is putting them in function declarations the only way to do it?
Denis Lisov
@tanriol
Jan 08 2018 17:56
They can also come from type declarations (structs, etc.)