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.1k views
1 answer
    I wrote the following code to read an array of integers from stdin: use std::io::{self, BufRead}; fn main() ... out. Can anyone give me a hint? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
823 views
1 answer
    The implementation of std::mem::drop is documented to be the following: pub fn drop<T>(_x: T) { } As ... toilet closure is placed in its stead? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.6k views
1 answer
    I want to split a string and return Vec<String> from my function. It has to be Vec<String> and not Vec<&str ... errors. Is there an easier way? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.2k views
1 answer
    Here is my directory structure: lowks@lowkster ~/src/rustlang/gettingrusty $ tree . . ├── Cargo.lock ├── Cargo.toml ... rest of the files too? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.0k views
1 answer
    I am trying to convert a vector of &str pairs into a HashMap with the following code snippet: use std:: ... cloned() fixes that problem. See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
866 views
1 answer
    Considering the following code: fn foo<'a, T: 'a>(t: T) -> Box<Fn() -> &'a T + 'a> { Box:: ... not understand the conflict. How can I fix it? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.0k views
1 answer
    It would be nice if Rust's Option provided some additional convenience methods like Option#flatten and Option#flat_map, ... brand new to Rust. See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.0k views
1 answer
    I've constructed a closure example that I can't get to work, nor can I find any reason why it shouldn't work. Why does it ... ^^^^^^^^^^^^^^^^^^ See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.7k views
1 answer
    This MWE shows the use of tokio::spawn in for in loop. The commented code sleepy_futures.push(sleepy.sleep_n(2)); ... ", result.unwrap()) } } See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
939 views
1 answer
    I was implementing linked lists by following along too many linked lists. When trying to implement iter_mut(), I did it ... ) } } ??This works. See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
787 views
1 answer
    Here is a simplified version of what I want to archive: struct Foo<'a> { boo: Option<&'a mut String>, } ... way to tell this to the compiler? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
794 views
1 answer
    I'm reading Learning Rust With Entirely Too Many Linked Lists and I'm confused about why the linked list (stack) ... user 0m9.044s sys 0m0.004s See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.4k views
1 answer
    Why is the following invalid and what should I do instead to make it work? struct Foo; impl Foo { ... , yet with warnings. Playground See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
883 views
1 answer
    I'm trying to iterate over all possible byte (u8) values. Unfortunately my range literals in 0..256 are cast to u8 ... } Is there a better way? 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 pretty confused by the errors from this simple code (Playground): fn main() { let a = fn1("test123"); ... ? How can I fix the errors? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.1k views
1 answer
    I expected there to be something like: cargo install stopwatch but could not find it in the docs. Finding the ... not feel automated enough. :) See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.3k views
1 answer
    I expect the same result for both of these code samples: let maybe_string = Some(String::from("foo")); let ... ` found type `&'static str` See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.0k views
1 answer
    Is there an idiomatic way of initialising arrays in Rust. I'm creating an array of random numbers and was wondering ... i] = some_function(); } See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.0k views
1 answer
    I'm looking for the document about copy/move semantics of reference and mutable reference types. The following code snippet ... (or am I wrong?) See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
923 views
1 answer
    I need to align a struct to a 16 byte boundary in Rust. It seems possible to give hints about alignment ... ? Are there any work-arounds? 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 writing a server using actix-web: use actix_web::{post, web, Responder}; use serde::Deserialize; #[derive( ... 1` How should I resolve this? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
849 views
1 answer
    I'm so sorry to ask such a simple question... A day ago, I started learning Rust and tried the println! ... format style with sample code :( See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.1k views
1 answer
    I ran into an error: extern crate rustc_serialize; // 0.3.24 use rustc_serialize::base64::{self, FromBase64, ... am I having that error? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
982 views
1 answer
    I am working on a project where I am doing a lot of index-based calculation. I have a few lines ... arithmetics easier / more efficiently? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.1k views
1 answer
    Is there a more direct and readable way to accomplish the following: fn main() { let a = [1, 2, 3]; ... from n iterables which yields n-tuples? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.0k views
1 answer
    Is there a way to tell Cargo to install and build all my dependencies, but not attempt to build my application? I ... when I change my own code. 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 the following code which uses both Rc and Box; what is the difference between those? Which one is better? ... b1, b2); } playground link See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.2k views
1 answer
    The Rust book mentions that "it is almost always better to use a struct than a tuple struct." Other than ... case of having tuple structs. 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

...