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.3k views
1 answer
    I have a newtype and I want to implement Ord: use std::cmp::{Ord, Ordering}; struct MyType(isize); impl Ord for ... Rust? I hope not this way... See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.5k views
1 answer
    I currently have to use this to format a .expect() message: fn main() { let x: Option<&str> = None; x. ... ; } Is there a less verbose way? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.2k views
1 answer
    These two traits (std::ops::Add, core::ops::Add) provide the same functionality, and they both use the same ... opposed to one, of them exist? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.4k views
1 answer
    The first conversion using 'as' compiles, but the second one using the 'From' trait does not: fn main() { ... as' should also fail to compile? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
958 views
1 answer
    Say I define my own type in a Rust library, like so: struct Date { year: u16, month: u8, day: u8 } ... created; feel free to comment on that.) See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
914 views
1 answer
    If I have a struct that encapsulates two members, and updates one based on the other, that's fine as long ... the compiler saving me from here? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.1k views
1 answer
    I've got a struct defined that has a function which defines a static lifetime: impl MyStruct { pub fn doSomething( ... a way to achieve this? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.1k views
1 answer
    I know that in Rust there is no try/catch, and you can't throw a rolling save from the thread that is ... error is of type Any. Thanks! See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
897 views
1 answer
    In the Rustonomicon's guide to PhantomData, there is a part about what happens if a Vec-like struct has *const ... that my struct owns some Ts? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.6k views
1 answer
    I've seen a question similar to this one, but no one that tells me exactly how to implement Ord for a struct. ... are not a member of Ord. 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 trying to remove duplicates in the below example: struct User { reference: String, email: String, } fn main ... I have to do something else? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.0k views
1 answer
    I have a struct with string fields. I'd like to control how the memory for the strings is allocated. In ... with the arena lifetime, right? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
968 views
1 answer
    I'm taking an iterator of some type that must implement the trait A, and trying to convert it into a Vec of ... than whatever type they may be? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.0k views
1 answer
    Here's an example: use std::rc::Rc; #[derive(PartialEq, Eq)] struct MyId; pub fn main() { let rc_a_0 ... between the rc_a_* and rc_b_* pointers? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.2k views
1 answer
    I would like to take a mutable slice and copy the contents into two new mutable slices. Each slice being one half of ... ("{:?}", my_list); } See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
986 views
1 answer
    What is the stabilization process? Reading the release notes I see a lot of different standard library APIs and ... does an API become stable? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
912 views
1 answer
    Parameters can be passed to functions and modified: fn set_42(int: &mut i32) { *int += 42; } fn main() { ... it becomes a smaller "sub-slice". See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
964 views
1 answer
    Suppose I execute cargo new one --bin and cargo new two --bin then add the same dependency to ... compiled libraries to avoid recompilation? 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 encountered a confusing error about the use of a mutable and immutable borrow at the same time, after I expect ... and how I can avoid it. See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.1k views
1 answer
    A fixed-length array of a native type (or of a type that implements the Copy trait) can be cloned in Rust up ... array of length, say, 33? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
985 views
1 answer
    I can't seem to figure out why: let a = Box::new(5i32); let _:() = *a; tells me that the assigned type ... ::deref(&a); I get the expected &i32. See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.2k views
1 answer
    What does the error mean in this case: fn main() { let mut v: Vec<usize> = vec![1, 2, 3, 4, 5 ... equivalent, but this obviously isn't the case. See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.3k views
1 answer
    I've been looking over the documentation, and so far I haven't seen a built in function to safely move an item ... index: usize) -> Option<T>? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.2k views
1 answer
    Suppose I execute cargo new one --bin and cargo new two --bin then add the same dependency to ... compiled libraries to avoid recompilation? 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 encountered a confusing error about the use of a mutable and immutable borrow at the same time, after I expect ... and how I can avoid it. See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.2k views
1 answer
    A fixed-length array of a native type (or of a type that implements the Copy trait) can be cloned in Rust up ... array of length, say, 33? See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
901 views
1 answer
    I can't seem to figure out why: let a = Box::new(5i32); let _:() = *a; tells me that the assigned type ... ::deref(&a); I get the expected &i32. See Question&Answers more detail:os...
asked Oct 24, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.6k views
1 answer
    What does the error mean in this case: fn main() { let mut v: Vec<usize> = vec![1, 2, 3, 4, 5 ... equivalent, but this obviously isn't the case. 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

...