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
773 views
1 answer
    When I define a struct like this, I can pass it to a function by value without adding anything specific: #[ ... no copy in the first place. See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
788 views
1 answer
    I was playing around with Rust closures when I hit this interesting scenario: fn main() { let mut y = 10; let f = ... if I remove the call f(). See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
700 views
1 answer
    The derive attribute allows certain traits to be automatically implemented for data structures. The reference gives the ... by the compiler? See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.0k views
1 answer
    I have a struct that holds mutable references to trait objects: trait Task { fn do_it(&mut self); } struct Worker<'a ... How do I do it in Rust? See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
619 views
1 answer
    When I'm passing a object by reference to a struct's new() method, and the struct will own the object, is ... ::new_by_val(state2.clone()); } See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
680 views
1 answer
    I'm currently working on a project with Rust and Cargo. It works well, but I encounter a little issue: ... project, for development purpose... See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
713 views
1 answer
    I'd like to use Serde to parse some JSON as part of a HTTP PATCH request. Since PATCH requests don't pass ... such as one using a custom enum. See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
950 views
1 answer
    I have ownership of an array of size 3 and I would like to iterate on it, moving the elements out as I ... ^ cannot move out of borrowed content See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
984 views
1 answer
    I am going through Rust's getting started and I need to get the rand crate on my system. I'm not ... -index` specified package has no binaries See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
613 views
1 answer
    I don't understand why Result exists in Rust. I can see how Option can be useful, but using Result just seems to ... how this can be the case. See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
793 views
1 answer
    I was reading through the Rust documentation and came across the following example and statement Using a return as ... the former be encouraged? See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
813 views
1 answer
    In Scala, there is a method named toMap that works on any list of tuples and converts it to a map where the ... closest thing to toMap in Rust? See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.3k views
1 answer
    I have a string that looks like this "090A0B0C" and I would like to convert it to a slice that looks ... a slice of multiple integer values. See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
875 views
1 answer
    Here are two functions: fn foo<I>(iter: &mut I) where I: std::iter::Iterator<Item = u8>, { let x = ... will compile too. Where am I mistaken? See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
731 views
1 answer
    Is there a way to minimize the following feature check? #[cfg(feature = "eugene")] pub mod ... meaning and be more ergonomic. See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.1k views
1 answer
    Here's an invalid Rust program (Rust version 1.1) with a function that does an HTTP client request and returns only ... a move, similar to C++? See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
715 views
1 answer
    impl Traits can be used as function arguments. Are there differences between this and a generic function with a trait ... Foo>(_: T) {} See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.4k views
1 answer
    I'm attempting to simply convert a slice to a vector. The following code: let a = &[0u8]; let b: Vec<u8> = ... of type `&u8` What am I missing? See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.0k views
1 answer
    I'm writing a program in Rust and I have some tests for it. I wrote a helper function for these tests, but ... so as not to get the warnings? See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.1k views
1 answer
    I'd like to initialize a vector of zeros with a specific size that is determined at runtime. In C, it would be ... zeros(pattern.len()+1); } See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
609 views
1 answer
    I've gotten as far as having the custom attribute invoked: #[plugin_registrar] pub fn registrar(reg: &mut rustc:: ... How do I achieve that? See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.1k views
1 answer
    I want to get the first character of a std::str. The method char_at() is currently unstable, as is String:: ... ; let ch = char_vec[0]; See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.0k views
1 answer
    I am trying to disable dead code warnings. I tried the following cargo build -- -A dead_code ? rla git:( ... I pass rustc arguments to cargo? See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.1k views
1 answer
    I want to conditionally compile my source code using cfg with Cargo, after Googling for a while, it seems that the ... -18 01:50:48 +0000) See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
832 views
1 answer
    What is the easiest way to pad a string with 0 to the left so that "110" = "00000110" "11110000" = "11110000" I ... : format!("{:08}", string); See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
824 views
1 answer
    I just took the dive into Rust and want to make some basic math functions that are generic. I have the following ... of traits to my goal here. See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
894 views
1 answer
    The following command $ cargo build produces a non-optimized build with debugging information. On the ... meaningful profiling information. See Question&Answers more detail:os...
asked Oct 17, 2021 in Technique[技术] by 深蓝 (71.8m points)
0 votes
1.1k views
1 answer
    How to convert Vec<char> to string form so that I can print it? 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

...