by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    James Sewell
    @jamessewell
    I suppose it depends where the code lives too, you’d be less inclined to panic in a public library fn right?
    Paul Masurel
    @fulmicoton
    Yes.
    Denis Lisov
    @tanriol
    You can make these dependencies optional and make the binary build require them. cargo-install by default installs all binaries (it's not limited to just one).
    Paul Masurel
    @fulmicoton
    @tanriol thanks for the info.
    Making the dependencies optional is a bit cumbersome if there is a lot of them, I think I'll stick to different crate for tantivy-cli as there are a lot of those...
    Denis Lisov
    @tanriol
    That's certainly a possible choice :-) although I'd guess a good helper crate like quicli can replace quite a number of them.
    Judson Lester
    @nyarly
    Confirming: impl Trait is not yet available as the return type of trait methods and associated functions?
    In stable, anyway?
    trsh
    @trsh
    Hi guys I have this error no idea why
    pub fn process(&mut self, pd: Box<ProcessData>) -> Box<Future<Item = (), Error = String>> {
        .....
    
        self.processData = Some(pd);
    
        let bd = &self.processData;
        let ss = &bd.unwrap();
    let ss = &bd.unwrap();
    | ^^ cannot move out of borrowed content
    But I am borrowing it?!
    Guillaume P.
    @TeXitoi
    @trsh let ss = bd.as_ref().unwrap();
    bd.unwrap() move out the value, Option::as_ref is exactly what you need
    trsh
    @trsh
    @TeXitoi tnx, it worked
    trsh
    @trsh
    This programming language can take weeks to acompilsh simple things :/
    muutable, immutable, cant barrow here .. so pissed going on vacation orsmth
    Dylan DPC
    @Dylan-DPC
    @trsh yeah but all this ensures you write better and safe code :)
    trsh
    @trsh
    Isn't this a bug?
    fn forward_process(&mut self, node: &'a NodeData) -> Box<Future<Item = (), Error = String>> {
        let nodes = self.nodes.expect("Nodes empty, can't process");
        let connection_nodes_flat = node
          .outputs
          .iter()
          .flat_map(|output| {
            output
              .connections
              .iter()
              .flat_map(|c| {
                let c_node = nodes
                  .get(&c.node.to_string())
                  .expect("Unknown output connection node");
    
                vec![self.back_process(c_node), self.forward_process(c_node)]
              })
              .collect::<Vec<_>>()
          })
          .collect::<FuturesOrdered<_>>();
    
        Box::new(connection_nodes_flat.for_each(|_| Ok(())))
      }
    Im borrowing nodes immutable, and then mutable! Could set it to None in every moment and references would messed up
    Thibault Delor
    @thibaultdelor
    As far as i can tell nodes is mutable because it belong to self
    trsh
    @trsh
    let nodes
    Fredrik Portström
    @portstrom

    @trsh Well, Rust isn't Yet Another Language that just puts some new syntax on old features from the 60s that every programmer already knows, so learning Rust is challenging in the same way as learning programming in the first place. Python I learned in 30 minutes reading a blog post. Rust I learned in two months making a toy program. After a few more months of Rust, it's as productive as Python, but gives me the same performance and control as C.

    I think that Rust will be highly influential, and soon more languages will have ownership, borrowing, controlled mutability and many other features from Rust, and these features will become part of what every programmer knows. The next generation of programmers who will have this knowledge will likely not say that Rust is a particularly difficult language.

    Michal 'vorner' Vaner
    @vorner
    Well, there's also the other part about Rust being rather low-level. It expects you to know what memory is, the difference between stack and heap, that you need to allocate and free it, when it happens, etc. It's syntax and semantics are rich, which means a lot to learn. You can get away without knowing this in python. Sure, you get something in return after learning all that, but I don't think the next generations will consider Rust one of the easy languages. Anyway, even today, Rust is probably easier to learn than C++ (the difference is, in Rust it's the compiler that complains, with C++ it's the colleagues).
    trsh
    @trsh
    tnx for this info
    Maximilian Alexander
    @mbalex99
    Hi all. I'm new to Rust, but what's a good place to learn (besides the rust-book) about Rc, Arc, and Box<T>
    Dmitriy
    @dpogretskiy
    docs.rs is a good one, you can read sources and all the docs, inluding standard library
    Rust -> Standard library API reference, somewhere around there
    Ash
    @ashthespy
    The tests also helps quite a bit :-)
    Dmitriy
    @dpogretskiy
    Yeah, use it and see what happens, but if you are obsessed with reading, there is plenty
    Maximilian Alexander
    @mbalex99
    Thanks a lot!
    polypus74
    @polypus74
    Should the following fail with a stack overflow, because it is:
    fn main() {
        let mut img = [0 as u8; 8000 * 6000];
        for (y, ps) in img.chunks_mut(8000).enumerate() {}
    }
    Dmitriy
    @dpogretskiy
    it's a huge stack allocated array, my bet is yes
    polypus74
    @polypus74
    doh. when i removed the for loop it was not overflowing, so i was thinking it was some sort of limit of chunks_mut, which being lazy would be odd. but i see now that the for loop was just pushing the stack memory to it's limit probably.
    Farzeen
    @happycoder97

    I was trying to run some unit tests using gtk-rs. Even though I specified cargo test -- --test-threads=1, gtk::init().unwrap() panics with the following message:

    Attempted to initialize GTK from two different threads.

    Looks like although cargo is running tests two sequentially, it is running different tests in different threads and run those threads one after another. How to disable this?

    Björn Lindström
    @bkhl
    happycoder97, cargo test -- --test-threads=1
    Thibault Delor
    @thibaultdelor
    In Rust it's the compiler that complains, with C++ it's the colleagues - @vorner
    Quote of the week I believe :smile:
    Farzeen
    @happycoder97
    Yeah.. that was a good one :D
    @bkhl already tried that :(
    Thibault Delor
    @thibaultdelor
    When it’s not your colleagues, it’s your customers in your bug tracker ^^
    Farzeen
    @happycoder97
    :+1:
    Thibault Delor
    @thibaultdelor
    @happycoder97 Can you send your whole code?
    Thibault Delor
    @thibaultdelor
    Can you just ignore the error? I mean if it’s already initialised, all good
    Farzeen
    @happycoder97
    It panics : (
    Thibault Delor
    @thibaultdelor
    does it panics because you unwrap
    or before the unwrap