Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

Recent questions tagged RUST

0 votes
1.2k views
1 answer
    I want to generate a unique id for every type at compile time. Is this possible in Rust? So far, I have ... <TBase>::m_nextTypeId = 0; } See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.1k views
1 answer
    I'm writing a simple tokenizer in Rust but I'm having trouble. I've simplified the code a bit for the sake of ... ? It seems a little hack-ish. See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
885 views
1 answer
    I have an object of type Arc<RwLock<SessionData>> And I have a method that is supposed to take some kind of ... to the provider of the value. See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.3k views
1 answer
    I want to execute another process and normally want to wait until it has finished. Lets say we spawn and wait ... know if there's another way. See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
876 views
1 answer
    I tried to create vector of closures: fn main() { let mut vec = Vec::new(); vec.push(Box::new(|| 10)); ... type of vec and why is it that way? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
732 views
1 answer
    I have a struct that is not Send because it contains Rc. Lets say that Arc has too big overhead, so I want ... for the MyStruct to not be Send. See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
974 views
1 answer
    I have the following code that tries to take a reference to a trait object from a boxed trait: trait T {} ... properly borrow &T from Box<T>? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
996 views
1 answer
    let arr0 = [0u8; 15]; let arr1 = [0u8; arr0.len()]; // this fails I think the compiler should be able to ... 2015-03-21) (built 2015-03-22) See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.0k views
1 answer
    Consider the following snippet: fn example(current_items: Vec<usize>, mut all_items: Vec<i32>) { for i in ... primitive type reference by value? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.1k views
1 answer
    I have a struct with a lifetime: struct HasLifetime<'a>( /* ... */ ); There is there is an ... bar_to_foo with impl Trait? Playground link See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
840 views
1 answer
    I want to use the dijkstra function from the pathfinding crate: pub fn dijkstra<N, C, FN, IN, FS>( ... ? use pathfinding::num_traits::Zero; See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
872 views
1 answer
    I'm trying to write a function to return the mean of a Vector. I want it to work with generic types but I' ... . How should I go about this? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.0k views
1 answer
    I need to store a fn(I) -> O (where I & O can be references) in a 'static struct. O needs ... ` dropped here while still borrowed } playground See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
862 views
1 answer
    I'm reading a Rust book and I am confused by this example: use std::fmt::Display; fn main() { test(" ... this fail and the second call work? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.1k views
1 answer
    What's the best way to read from a type implementing the std::io::Read trait when the contents of the ... a convenient way to achieve this? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
768 views
1 answer
    I'm having trouble writing a function that takes a collection of strings as parameter. My function looks ... strings and string references? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
824 views
1 answer
    In Rust 1.3.0, the Deref trait has the following signature in the documentation: pub trait Deref { type Target: ... . What am I missing here? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.0k views
1 answer
    My first thought is to map the Option, but I can't use try! from inside of the closure. The match statement looks ... ?), None => None }) } See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
999 views
1 answer
    fn main() { let mut a = String::from("a"); let closure = || { a.push_str("b"); }; closure(); } This ... won't it be borrowed when I return a? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.2k views
1 answer
    I have an enum with two variants: enum DatabaseType { Memory, RocksDB, } What do I need in order to make a conditional if ... //.......... } } See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
993 views
1 answer
    I have this source: pub fn draw<G, C>(&self, font: &mut C, draw_state: &DrawState, transform: Matrix2d, g: ... Graphics<Texture = C::Texture>, See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
892 views
1 answer
    If I have a type like MyEnum<T>, how can I map it in cases where not every variant is parameterized? For ... MyEnum<String> = other_cases; o } See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.0k views
1 answer
    I can't figure out the lifetime parameters for this code. Everything I try usually results in a compiler error: ... running"); } Rust Playground See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.3k views
1 answer
    I'm using the chrono crate; after some digging I discovered the DateTime type has a function timestamp() which could ... to convert it back? } See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.2k views
1 answer
    I'm doing some bit twiddling and I'd like to print all the bits in my u16. let flags = ... make it print flags: 0b0000000000101100? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.1k views
1 answer
    I have two structs, A and B, and I want to use a HashMap<A, B>. I have a piece of code like this ... Why is there no implementation in the docs? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.3k views
1 answer
    I have written a function to prompt for input and return the result. In this version the returned string includes a ... the ' ' with ''). See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.4k views
1 answer
    I want to write output of my function to a file. I expected that write_fmt is what I require: use std ... t much available in the documentation. See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
Ask a question:
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...