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
748 views
1 answer
    I have a trait that defines an interface for objects that can hold a value. The trait has a way of ... better way than BorrowedOrOwned<T>? See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
983 views
1 answer
    I need to split a String (not &str) by another String: use std::str::Split; fn main() { let x = " ... problem of splitting by String, not &str. See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
631 views
1 answer
    I am trying to calculate legal chess moves and am having problems satisfying the borrow checker. I have a struct ... so the code can compile? See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
980 views
1 answer
    I'm reading a series of bytes from a socket and I need to put each segment of n bytes as a item in a struct. use ... be 24 bits (8 + 16 = 24)? See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
739 views
1 answer
    Is it possible to use the Entry API to get a value by a AsRef<str>, but inserting it with Into<String>? This ... Maybe in a neat way with Cow? See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
709 views
1 answer
    Context I have a case where multiple threads must update objects stored in a shared vector. However, the ... the size of indices_to_update. See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
650 views
1 answer
    I'm having some trouble trying to grasp why I can't return an &str value generated from a String (goodness, when ... enough to be useful to me. See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
705 views
1 answer
    In Rust, this works: fn main() { let a = [0; 32]; println!("{:?}", a); } but this doesn't: fn main ... it's detection. Or why doesn't it work? See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.1k views
1 answer
    The following code segment gives me an error: use std::rc::Rc; // Definition of Cat, Dog, and Animal (see ... since it's a compile-time concept. See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.2k views
1 answer
    I have the code below. With the commented out parts, it's working. When I uncomment the parts it does not ... required by `std::thread::spawn` See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.5k views
1 answer
    I'm implementing combsort. I'd like to create fixed-size array on the stack, but it shows stack overflow. ... s really wrong with this code? See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
814 views
1 answer
    I'd like to use a HashMap to cache an expensive computation that's dependent on other entries in the map. The ... like to update cache as well. See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.1k views
1 answer
    I've been messing around with traits using Rust and I've come across a problem. Here's some code: struct Foo; ... ^^ cannot infer type for `B` See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
635 views
1 answer
    I have a trait with two associated functions: trait WithConstructor: Sized { fn new_with_param(param: usize) -> Self; fn ... { field: 0u32 }; } See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.0k views
1 answer
    How I can create a HashMap literal in Rust? In Python I can do it so: hashmap = { 'element0': { 'name': 'My New ... , map[string]Node {} } } } } See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
844 views
1 answer
    I was looking through the singly linked list example on rustbyexample.com and I noticed the implementation had no ... outside the append method. See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
737 views
1 answer
    I have the following code: pub struct Canvas<'a> { width: isize, height: isize, color: Color, surface: Surface, ... let, then it works; why? See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
811 views
1 answer
    The Rust book calls the ref keyword "legacy". As I want to follow the implicit advice to avoid ref, how can I do it in ... => &mut i, // } } } See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
913 views
1 answer
    pub struct WidgetWrap { // ... widget: RefCell<Box<Any>>, } At some point I want to cast Box<Any> ... the concepts involved in the above task. See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.2k views
1 answer
    I want to get a length of a string which I've split: fn fn1(my_string: String) -> bool { let mut segments = ... ^^^ How can I fix this error? See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
924 views
1 answer
    I'm trying to implement a trait which contains a generic method. trait Trait { fn method<T>(&self) -> T; ... I write the impl block correctly? See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
924 views
1 answer
    It seems that if you borrow a reference to a struct field, the whole struct is considered borrowed. I've managed ... | - first borrow ends here See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
789 views
1 answer
    I'm having a hard time with the borrow checker. for item in self.xxx.iter() { self.modify_self_but_not_xxx(item); ... from within a for-loop)? See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
738 views
1 answer
    I understand you're not allowed to create two mutable references to an object at once in Rust. I don't entirely ... s.push_str(" test"); } See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
741 views
1 answer
    I want to create a macro that prints "Hello" a specified number of times. It's used like: many_greetings!(3 ... a new expression into the macro. See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
706 views
1 answer
    Is it possible to insert a struct into a map where the key is owned by the value being inserted? When using ... the struct in other contexts). See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
892 views
1 answer
    I want to write a server using the current master branch of Hyper that saves a message that is delivered by a POST ... no clue how to do that. See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
904 views
1 answer
    I have a function that calls another function which returns a Result. I need to check if the Result is Ok or ... idiomatic Rust way to do this? See Question&Answers more detail:os...
asked Oct 17, 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

...