I ran cargo run command and got: error: expected a trait, found type --> src/main.rs:10:6 | 10 | impl const Multiplier for Math { | ^^^^^^^^^^^^^^^^ error: could not compile rusty (bin "rusty") due to 1 previous error 2 posts - 2 participants Read…
fn main() { let s1 = String::from("ganesha"); // The String's metadata (pointer, length, and capacity) // is moved to s2; the actual heap data ("ganesha") is not copied. // so both will point same and single heap data. // let s2 = s1; //My question…
Hello everyone! Is more idiomatically to use io::stdin().read_line(&mut s).unwrap_or_else(|err| { eprintln!("Critical error: failed to read from stdin. Reason: {err}"); process::exit(1); }); than io::stdin().read_line(&mut s).expect("Critical error:…
I'm currently using tracing-subscriber to format output for a CLI app (stdout, stderr & optional log). I'm missing the ability to include parent span fields in the output as well as some nice-to-have customisations for the console output formatting.…
AI gives me an example, but unfortunately a collection growing should happen inside the iterator next(). struct GrowingIter { data: Vec<String>, index: usize, } impl Iterator for GrowingIter { type Item = String; fn next(&mut self) ->…
G'day folks, Today I'm working on a dictionary stemmer. The data required for this is several megabytes, so I want to keep as few copies around as possible. There are three traits involved here: docs.rs TokenFilter in tantivy_tokenizer_api - Rust…
Hi everyone, I have a case I am not sure why it is not valid, here is a small recreation of the issue in playground play.rust-lang.org Rust Playground A browser interface to the Rust compiler to experiment with the language here is the code of the…
I am trying to make a iterator like pattern (or builder pattern might be more accurate). Where I want to have a core function which will pass in bytes through the rest of the chain, and each part of the chain would decode it into a specific struct,…
I am trying to debug bevy's memory usage, which is at about 200MB (measured via COSMIC System Monitor and BTOP) for the window_resizing example (used because it does the least out of all the examples I looked at while still being a graphical…
Introduction I recently got into building a wayland client in rust on linux to get a feel for both linux windowing and rust IPC. I ended up getting stuck on step #1 which was to open a unix socket to a wayland compositor process because part of the…
I'm building an actor library and have ran into a sticking point. For context, the library is powered by macros, so I have a lot of leeway in terms of generating or modifying the implementation for a given actor on top of the code provided by the…
I'm trying to test a struct that calls back to a listener whenever its internal state changes using an interface like this: pub struct StateDetails { id: String, name: String, info: Vec<u16>, // ... } #[cfg_attr(test, mockall::automock)] pub trait…
Is it possible to get cargo doc to also create the documentation for build & dev dependencies? This would be really useful to have locally. I couldn't find anything in --help, the cargo book or github issues related to this. Can I really be the…
I have been lost for song long... I want to send this struct over the threads but the classic "some member that is under this struct doesnot implement the SEND trait" comes up. i did avoid this earlier by creating the struct inside the new thread…