These are chat archives for rust-lang/rust

15th
Oct 2018
Farzeen
@happycoder97
Oct 15 2018 07:28
pub trait ObjectType: FromGlibPtrBorrow<*mut <Self as ObjectType>::InstanceStructType>
Why do we need Self as ObjectType here? When do we usually need to cast Self?
John
@gitlabaccount624_gitlab
Oct 15 2018 18:20
noob here: looking at the docs for https://github.com/mitsuhiko/redis-rs and i see a try! macro. is this something new? i thought try! was replaced with question mark?
Denis Lisov
@tanriol
Oct 15 2018 18:21
Maybe the docs just haven't been updated since its introduction :-)
John
@gitlabaccount624_gitlab
Oct 15 2018 18:23
it said last updated 2 months ago
Denis Lisov
@tanriol
Oct 15 2018 18:23
At least the examples on the docs front page are mostly unchanged since mitsuhiko/redis-rs@cb60f27
John
@gitlabaccount624_gitlab
Oct 15 2018 18:23
but i'm not missing anything right?
question mark would work there instead of try?
Denis Lisov
@tanriol
Oct 15 2018 18:24
Yes, the modern way is to use ?
John
@gitlabaccount624_gitlab
Oct 15 2018 18:24
kk ty
Jonathan Steyfkens
@jonathansty
Oct 15 2018 19:52

Hi, I've got an issue with generic enums.

/// Declares in which queue(s) a resource can be used.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Sharing<I>
    where I: Iterator<Item = u32>
{
    /// The resource is used is only one queue family.
    Exclusive,
    /// The resource is used in multiple queue families. Can be slower than `Exclusive`.
    Concurrent(I),
}

How do I assign Sharing::Exclusive to a variable and then use it in a function that takes in a Sharing<I> as argument. The compiler can't tell what I would need to be.

Ash
@ashthespy
Oct 15 2018 22:19

Can someone give me some guidance here, been fighting the borrow checker for quite some time now.

prefetch_sender : Option<oneshot::Sender<()>>
fn signal_prefetch(&mut self) {
        if let Some(ref mut prefetch_sender) = self.prefetch_sender {
            let _ = prefetch_sender.send(());
        }
        // if self.prefetch_sender.is_some() && !self.prefetch_sender.unwrap().is_canceled() {
        //     let _ = self.prefetch_sender.unwrap().send(());
        // }

cannot more out of borrowed content

neither works ..
Denis Lisov
@tanriol
Oct 15 2018 22:25
if let Some(prefetch_sender) = self.prefetch_sender.take()
You cannot keep the oneshot sender after sending, so it needs to be moved out.
Ash
@ashthespy
Oct 15 2018 22:27
aah.
its so clear now that I think of it.