Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    tanriol
    @tanriol:matrix.org
    [m]
    Have you enabled the uuid's serde feature?
    Proem Meas
    @measproem
    Yes, I am using Uuid from uuid crate . I want the result from database deserialize to my struct by support uuid
    Yes uuid's serde feature
    tanriol
    @tanriol:matrix.org
    [m]
    Sounds like you may need this, not sure exactly... you may need to experiment a bit.
    1 reply
    Proem Meas
    @measproem
    I googled saw that but I didn't find sample code #[serde(with)]
    tanriol
    @tanriol:matrix.org
    [m]
    Something like #[serde(with = "uuid::serde::compact")] specified for that specific field, I think.
    Proem Meas
    @measproem
    image.png
    Not found uuid::serde::compact
    Proem Meas
    @measproem

    Hi all how can I access data Struck in Vec

    pub struct UserLoginTokenInfo{
        pub user_name: String,
        pub login_session: String,
    }
    pub struct UserLoginResponse {
        pub responsedlogin: Vec<UserLoginTokenInfo>,
    }

    I want get value user_name, login_session UserLoginResponse

    6 replies
    kushudai
    @kushudai
    Hello, I found a lot of github issues about this from 2015 but they seem all resolved. I also see the RFC that should prevent this but as far as I can tell, on stable 1.64 I can compile code that leaks a private type when it is returned from or a parameter to a function defined in a public trait.
    Perhaps I am simply misunderstanding...
    Here is an example that I think should not compile https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=0280d55b3d6bb68aeb450608c8f115af
    2 replies
    tanriol
    @tanriol:matrix.org
    [m]
    @kushudai: IIUC, this is expected as your type is marked pub so it's public despite being in a private module. If you mark it pub(crate) instead, you'll see a privacy error.
    4 replies
    chaosprint
    @chaosprint:matrix.org
    [m]
    quick question: why in Rust 2021, I still need this extern crate?
    tanriol
    @tanriol:matrix.org
    [m]
    It would be problematic to automagically pull in alloc in no_std environment without memory allocation, IIUC. There's a bit of discussion in rust-lang/rust#90507
    1 reply
    slby
    @slby:matrix.org
    [m]
    Is there an equivalent to this in tokio? smol::io::BufReader::new(smol::Unblock::new(reader))
    Марго
    @Margosha555
    Привет всем, я ищу старшего разработчика Rust, мне нужен опытный сеньор, за пределами РФ
    Опыт работы в C++ более 3 лет
    Rust от 1 года
    Опыт работы в блокчейне от 1 года
    tanriol
    @tanriol:matrix.org
    [m]
    <del>Удачи в поисках :-) вообще эта комната не очень активна, но вдруг повезёт.</del>
    On the second glance, I'd note that this it not a Russian-language room, so you may have posted this to the wrong toom.
    Indoood
    @indoood
    Hey everyone. I'm trying to make a library that serializes things using serde but I'd like better type-safety. Specifically: the format is much more restrictive than serde and I'd like field types incompatible with my format to be rejected at compile-time. I'd also like to have a separate trait/derive macro for this. Is there a good example of this or something similar being done in a crate somewhere?
    chaosprint
    @chaosprint:matrix.org
    [m]
    Hi, is it possible to chain method that does not return a Self?
    1 reply
    peckpeck
    @peckpeck
    yes, they would however be methods of different structs
    obj.methodA().methodB() works if methodB is defined on the return type of methodA
    Nacho Castillo
    @nachocodexx
    Hi, someone knows why sha2 crate autocompletion is not working ?
    image.png
    Sorry I know that this channel is not the RustCrypto but I could not find it, so I decide to post my doubt here.
    Nacho Castillo
    @nachocodexx
    :/ someone to help with the problem I described above.
    2 replies
    Evgeny Igumnov
    @evgenyigumnov
    Hello all! Simple question. I using Idea Rust plugin. It is awfully. A lot of time this IDE don not highlight my mistakes in code. Only after compilation I will know my code problems! Whats the best IDE for Rust? My simple question! Thank you for your advice .
    xiretza
    @xiretza:xiretza.xyz
    [m]
    thanks to the Language Server Protocol (and rust-analyzer in particular), you can use pretty much any modern IDE/advanced editor and get great rust support - personally I use neovim, but there are also a lot of people using plain vim, emacs or VSCode. Just make sure whatever you choose supports LSP.
    Evgeny Igumnov
    @evgenyigumnov
    Intellegent Idea do not support LSP ?
    xiretza
    @xiretza:xiretza.xyz
    [m]
    no, it doesn't seem to
    Evgeny Igumnov
    @evgenyigumnov
    I need visual studio... I will try it ) thanks
    xiretza
    @xiretza:xiretza.xyz
    [m]
    there's also Helix, an editor written in Rust :)
    Evgeny Igumnov
    @evgenyigumnov
    I do not like vi based editors
    For me enough Far Manager Editor or Midnight Commander Editor )
    Johannes Altmanninger
    @krobelus

    This program

    struct Foo {
        someString: String,
    }
    fn main() {
        let x: Vec<Foo> = Vec::new();
        x.sort_by_key(|foo| &foo.someString);
    }

    does not compile because

    lifetime may not live long enough
    returning this value requires that `'1` must outlive `'2`

    I guess I should use x.sort_by() instead in this case

    Denis Lisov
    @tanriol
    @krobelus Yeah, there's an issue about that (rust-lang/rust#34162)
    copoer
    @copoer:ooper.space
    [m]
    Howdy, Does anyone know a good room to discuss rust-bert related topics?
    peckpeck
    @peckpeck
    what is rust-bert ?
    copoer
    @copoer:ooper.space
    [m]
    Viktor Gal
    @vigsterkr

    does anybody know why cargo publish ignores the actual value of CARGO_PKG_VERSION? i'm overriding the pkg version in build.rs for a project using:

    println!("cargo:rustc-env=CARGO_PKG_VERSION=1.1.1");

    but cargo publish seems to ignore that version and goes with the version in Cargo.toml. note in case of cargo build this is not the case.

    elmeri
    @elmeri15391352_twitter

    yooo! Is there any way to extract the "index" (order of occurrence) of a struct field in a macro like this:

    macro_rules! example {
        (struct $name:ident {
             $($field_name:ident: $field_type:ty,)*
        }) => {
            struct $name {
                $($field_name: $field_type,)*
            }
        }
    }

    such that

    example! {
        struct Struct {
            a: i32,
            b: i32,
        }
    }

    would have the index 0 associated to a and 1 to b etc. (for use in a particular impl)? =)

    1 reply
    peckpeck
    @peckpeck
    i don't think so
    Denis Lisov
    @tanriol
    There's accepted RFC 3086 for this, but they're unstable at the moment.
    gitexp2050
    @gitexp2050
    I was been very much attracted by rust programming language. I need a tool and is anyone like to create in their own time as passion. please let me know
    5 replies
    RuRu92
    @RuRu92

    Hey all - got a question if someone mind helping. Got stuck on trying to understand why I get this error

    error[E0499]: cannot borrow `asks` as mutable more than once at a time
       --> src\domain\order.rs:148:37
        |
    139 | ...                   for lvl in asks.iter_mut() {
        |                                  ---------------
        |                                  |
        |                                  first mutable borrow occurs here
        |                                  first borrow later used here
    ...
    148 | ...                           asks.push_front(new_level);
        |                               ^^^^ second mutable borrow occurs here

    Here is the actual impl

       Side::ASK => {
                    let mut asks = self.ask;
                    let top_of_the_book = asks.front();
                    match top_of_the_book {
                        Some(mut level) => {
                            if level.price == order_entry.price {
                                level = &Self::update_level(level, &order_entry);
                            } else {
                                for lvl in asks.iter_mut() {
                                    if lvl.price > order_entry.price {
                                        let mut entries = HashMap::new();
                                        entries.insert(order_entry.user_order_id.clone(), order_entry.clone());
                                        let new_level = OrderLevel {
                                            price: order_entry.price.clone(),
                                            order_entries: entries,
                                        };
                                        asks.push_front(new_level);
                                    }
                                    if lvl.price < order_entry.price {
                                        continue;
                                    }
                                    if lvl.price == order_entry.price {
                                        lvl.order_entries.insert(order_entry.user_order_id.clone(),
                                                                 order_entry.clone());
                                    }
                                }
                            }
                        }

    Essentially, I just want to update the order book level with the order request. But it seems like I cant simply iterate over the levels and find one to update or insert new. How would this be done in idiomatic rust?

    9 replies
    gitexp2050
    @gitexp2050
    Any note taking app is build on rust to go through for reference?
    xiretza
    @xiretza:xiretza.xyz
    [m]
    gitter having a bit of a moment there...