Welcome to Jonic Developer Community for programmer and developer-Open, Learning and Share
Login
Remember
Register
Ask
Q&A
All Activity
Hot!
Unanswered
Tags
Categories
Users
Ask a Question
Ask a Question
Categories
All categories
Topic[话题] (13)
Life[生活] (4)
Technique[技术] (2.1m)
Idea[创意] (3)
Jobs[工作] (2)
Others[杂七杂八] (18)
Code Example[编程示例] (0)
Recent questions tagged rust
0
votes
1.8k
views
1
answer
rust - What's the difference between len() and capacity()?
When I create a vector, the length and the capacity are the same. What is the difference between these methods? fn main() { let vec = vec![1, 2, 3, 4, ... "Capacity: {}", vec.capacity()); // Capacity: 5 } See Question&Answers more detail:os...
asked
Oct 24, 2021
in
Technique[技术]
by
深蓝
(
71.8m
points)
rust
0
votes
1.3k
views
1
answer
rust - "Variable does not live long enough" when returning a Result containing a reference but it does live long enough
I'm implementing a small utility and the compiler is telling me that a variable (a TcpStream) does not live long enough and is advising me to find a way to ... the problem is solved, but I don't know why. See Question&Answers more detail:os...
asked
Oct 24, 2021
in
Technique[技术]
by
深蓝
(
71.8m
points)
rust
0
votes
1.4k
views
1
answer
rust - Is it possible to mark a potentially uninitialized variable as good without using unsafe or panicking?
Is it possible to explain to the compiler that the v variable is good at the line marked as 1 without using unsafe or code that may call panic ... use potentially bad things like unsafe or Option::unwrap See Question&Answers more detail:os...
asked
Oct 24, 2021
in
Technique[技术]
by
深蓝
(
71.8m
points)
rust
0
votes
1.5k
views
1
answer
rust - Mutable borrow in a getter not living long enough
pub type Data = i32; pub struct Foo { data: Data, } impl Foo { pub fn data_mut(&mut self) -> &mut Data { &mut self.data } } pub struct ... and covering with tests). What's the lifetime issue there? See Question&Answers more detail:os...
asked
Oct 24, 2021
in
Technique[技术]
by
深蓝
(
71.8m
points)
rust
0
votes
1.3k
views
1
answer
rust - How to return a future combinator with `&self`
I have this piece of code using futures v0.1: impl ArcService for (Box<MiddleWare<Request>>, Box<ArcService>) { fn call(&self, req: Request, res: ... hyper::Service and using Rust v1.25.0 (nightly) See Question&Answers more detail:os...
asked
Oct 24, 2021
in
Technique[技术]
by
深蓝
(
71.8m
points)
rust
0
votes
1.4k
views
1
answer
rust - Can an FFI function modify a variable that wasn't declared mutable?
fn main() { let val = 0; unsafe { foo(&val) } } extern "C" { pub fn foo(val: *const u32); } Implementation in C: void foo(unsigned* ... unchanged even though I'm passing a pointer to the local variable? See Question&Answers more detail:os...
asked
Oct 24, 2021
in
Technique[技术]
by
深蓝
(
71.8m
points)
rust
0
votes
2.3k
views
1
answer
rust - What's the fastest way of finding the index of the maximum value in an array?
I have a 2D array of type f32 (from ndarray::ArrayView2) and I want to find the index of the maximum value in each row, and put the index value into ... that in Rust. What's the fastest way of doing so? See Question&Answers more detail:os...
asked
Oct 24, 2021
in
Technique[技术]
by
深蓝
(
71.8m
points)
rust
0
votes
1.8k
views
1
answer
rust - What does it mean for a trait to have a lifetime parameter?
I understand how lifetime parameters apply to functions and structs, but what does it mean for a trait to have a lifetime parameter? Is it a shortcut to ... to its methods, or is it something else? See Question&Answers more detail:os...
asked
Oct 24, 2021
in
Technique[技术]
by
深蓝
(
71.8m
points)
rust
0
votes
1.3k
views
1
answer
rust - Is it possible to create a macro which counts the number of expanded items?
Is it possible to create a macro which counts the number of expanded items? macro_rules! count { ($($name:ident),*) => { pub enum Count { $( $name = 1 << $i ... expansion index ),* } } } count!(A, B, C); See Question&Answers more detail:os...
asked
Oct 24, 2021
in
Technique[技术]
by
深蓝
(
71.8m
points)
rust
0
votes
1.8k
views
1
answer
rust - Macro for defining trait aliases
According to this isuue issue and this answered question it is not possible to simply define a trait alias like: trait Alias = Foo + Bar; The workaround ... define such a macro? How should it look like? See Question&Answers more detail:os...
asked
Oct 24, 2021
in
Technique[技术]
by
深蓝
(
71.8m
points)
rust
0
votes
1.2k
views
1
answer
rust - How do I return an Iterator that's generated by a function that takes &'a mut self (when self is created locally)?
Update: The title of the post has been updated, and the answer has been moved out of the question. The short answer is you can't. Please see my answer to ... stupid? I'm not sure where to go from here. See Question&Answers more detail:os...
asked
Oct 24, 2021
in
Technique[技术]
by
深蓝
(
71.8m
points)
rust
0
votes
1.5k
views
1
answer
rust - Can I create a mutable slice &mut [u8] from a single byte (u8)?
Sometimes I want to read a single byte from a std::io::Reader. If I try to do this: use std::io::{self, Read}; fn main() { let mut byte: u8 = ... don't know if it's possible or not and would like to know. See Question&Answers more detail:os...
asked
Oct 24, 2021
in
Technique[技术]
by
深蓝
(
71.8m
points)
rust
0
votes
1.6k
views
1
answer
rust - How can I reuse a box that I have moved the value out of?
I have some non-copyable type and a function that consumes and (maybe) produces it: type Foo = Vec<u8>; fn quux(_: Foo) -> Option<Foo> { Some( ... notbox` notbox }) } Is it possible to work around that? See Question&Answers more detail:os...
asked
Oct 24, 2021
in
Technique[技术]
by
深蓝
(
71.8m
points)
rust
0
votes
1.4k
views
1
answer
rust - How do I create a function that accepts an iterator of i32s as either values or references and sums them?
Is there a way to have a single function that accepts an iterator to either values or references? If not, is there a way to rewrite one or both of the tests so ... 1)); f64::from(sum) / f64::from(len) } See Question&Answers more detail:os...
asked
Oct 24, 2021
in
Technique[技术]
by
深蓝
(
71.8m
points)
rust
0
votes
1.4k
views
1
answer
rust - Confused about using trait with lifetime as generic parameter constraint
I am trying to make some kind of decoder, that will be able to deserialize entries without actually copying memory, just by mapping values to some ... solution, or I should refactor the code somehow? See Question&Answers more detail:os...
asked
Oct 24, 2021
in
Technique[技术]
by
深蓝
(
71.8m
points)
rust
0
votes
1.6k
views
1
answer
rust - How can I have an unused type parameter in a struct?
I'm trying to update some older code I wrote that basically looks like: trait Foo<T>{} struct Bar<A, B: Foo<A>>{ b: B } This used to work ... way to handle this situation now, or am I missing something? See Question&Answers more detail:os...
asked
Oct 24, 2021
in
Technique[技术]
by
深蓝
(
71.8m
points)
rust
0
votes
1.7k
views
1
answer
rust - How to pattern match on values inside a type implementing Deref, such as Box, without copying the contents?
I have data contained inside a Box, and would like to pattern match on it without accidentally copying the Box's contents from the heap to the stack; how do I ... => {} SomeEnum::AnotherEntry => {} } } See Question&Answers more detail:os...
asked
Oct 24, 2021
in
Technique[技术]
by
深蓝
(
71.8m
points)
rust
0
votes
1.7k
views
1
answer
rust - Option<Receiver> Moved in Previous Loop Iteration
I'm spawning a thread that does some work. Sometimes I want this thread to die after the work is finished, other times I want it to wait for more work to do. To do ... _) => panic!("Oh no!"), } } }); } See Question&Answers more detail:os...
asked
Oct 24, 2021
in
Technique[技术]
by
深蓝
(
71.8m
points)
rust
0
votes
1.4k
views
1
answer
rust - Getting 'Missing Lifetime specifier' error
This is my code: use std::ptr; struct Query<T>{ data: T, prev: & Query<T>, next: & Query<T>, } impl<T> Query<T>{ fn new(name: T) - ... specifier' where I am referencing &Query<T>. How do I fix this error? See Question&Answers more detail:os...
asked
Oct 24, 2021
in
Technique[技术]
by
深蓝
(
71.8m
points)
rust
0
votes
1.4k
views
1
answer
rust - Is there a way that we can convert from futures 0.1 to the standard library futures?
The async/await feature is coming soon, but there are a lot of libraries still using futures 0.1. How do we convert between the two? Convert an async future to 0. ... ; //how can I achieve this ? Ok(()) } See Question&Answers more detail:os...
asked
Oct 24, 2021
in
Technique[技术]
by
深蓝
(
71.8m
points)
rust
0
votes
1.7k
views
1
answer
rust - Is it possible to have a heterogeneous vector of types that implement Eq?
I want a vector for elements that contain a trait such as Eq and I need heterogeneous vectors. For example: let mut x: Vec<Eq> = Vec::new() ... pointers to things I can compare regardless of their types? See Question&Answers more detail:os...
asked
Oct 24, 2021
in
Technique[技术]
by
深蓝
(
71.8m
points)
rust
0
votes
1.3k
views
1
answer
rust - Explain the behavior of *Rc::make_mut and why it differs compared to Mutex
I needed to pass a resource between several functions which use a closure as an argument. And within these the data was handled, but it looked for that ... without the use of Mutex, I have some doubts. See Question&Answers more detail:os...
asked
Oct 24, 2021
in
Technique[技术]
by
深蓝
(
71.8m
points)
rust
0
votes
1.5k
views
1
answer
rust - Lifetimes for method returning iterator of structs with same lifetime
Assume the following contrived example: struct Board { squares: Vec<i32>, } struct Point<'a> { board: &'a Board, x: i32, y: i32, } impl ... structs whose lifetimes are tied to the struct creating them? See Question&Answers more detail:os...
asked
Oct 24, 2021
in
Technique[技术]
by
深蓝
(
71.8m
points)
rust
0
votes
2.0k
views
1
answer
rust - How to clone last element from vector?
I'm trying to write code that gets the last element of some vector and do different actions (including mutation of the vector) depending on that element. ... borrowing. Why does my code fails to compile? See Question&Answers more detail:os...
asked
Oct 24, 2021
in
Technique[技术]
by
深蓝
(
71.8m
points)
rust
0
votes
2.0k
views
1
answer
rust - How do I read multiple integers from a single line of stdin?
To learn Rust, I'm looking at things like the HackerRank 30 days challenge, Project Euler, and other programming contests. My first obstacle is to read ... ; How do I do this idiomatically in Rust? See Question&Answers more detail:os...
asked
Oct 24, 2021
in
Technique[技术]
by
深蓝
(
71.8m
points)
rust
0
votes
1.5k
views
1
answer
rust - Why do I get an "overflow evaluating the requirement" error for a simple trait implementation?
I'm getting an error[E0275]: overflow evaluating the requirement on this simple code, and I don't know how to resolve it. The error message suggests adding a ... <&Foo<Foo<Foo<...>>>>` for `String` See Question&Answers more detail:os...
asked
Oct 24, 2021
in
Technique[技术]
by
深蓝
(
71.8m
points)
rust
0
votes
1.6k
views
1
answer
rust - Is it possible to populate a large set at compile time?
We have a 'delete all my data' feature. I'd like to delete a set of IPs from many many web log files. Currently at runtime I open a CSV ... have only a single static binary to deploy with no dependencies. See Question&Answers more detail:os...
asked
Oct 24, 2021
in
Technique[技术]
by
深蓝
(
71.8m
points)
rust
0
votes
1.7k
views
1
answer
rust - Why isn't this rvalue promoted to an lvalue as specified in the reference?
The Rust Reference says: The left operand of an assignment or compound-assignment expression is an lvalue context, as is the single operand of a unary ... only doesn't work for (compound-)assignments? See Question&Answers more detail:os...
asked
Oct 24, 2021
in
Technique[技术]
by
深蓝
(
71.8m
points)
rust
Page:
1
2
3
4
5
6
...
33
next »
Ask a question:
Welcome to Jonic Developer Community for programmer and developer-Open, Learning and Share
Just Browsing Browsing
[1] Android Studio profiler menory 不显示?
[2] datetime - Elixir equivalent for Ruby on Rails time helpers (e.g. 1.day.ago)
[3] Convert html + css including grid layout to .pdf using php
[4] 这段Python代码怎么优化?
[5] java - How to save data from JEditorPane?
[6] python - PYGAME - Move Character with Vector
[7] r - How to subset .Rmd files in a directory using list.files
[8] c# - How to fix 'Gatt write characteristic FAILED.' exception in xamarin forms?
[9] I got error array_merge Expected parameter 2 to be in laravel 8 factory?
[10] 在一个canvas上再绘制叠加一个canvas,报错,如下图和代码
548k
questions
547k
answers
4
comments
55.4k
users
Most popular tags
javascript
python
c#
java
How
android
c++
php
ios
html
sql
r
c
node.js
.net
iphone
asp.net
css
reactjs
jquery
ruby
What
Android
objective
mysql
linux
Is
git
Python
windows
Why
regex
angular
swift
amazon
excel
algorithm
macos
Java
visual
how
bash
Can
multithreading
PHP
Using
scala
angularjs
typescript
apache
spring
performance
postgresql
database
flutter
json
rust
arrays
C#
dart
vba
django
wpf
xml
vue.js
In
go
Get
google
jQuery
xcode
jsf
http
Google
mongodb
string
shell
oop
powershell
SQL
C++
security
assembly
docker
Javascript
Android:
Does
haskell
Convert
azure
debugging
delphi
vb.net
Spring
datetime
pandas
oracle
math
Django
联盟问答网站-Union QA website
Xstack问答社区
生活宝问答社区
OverStack问答社区
Ostack问答社区
在这了问答社区
在哪了问答社区
Xstack问答社区
无极谷问答社区
TouSu问答社区
SQlite问答社区
Qi-U问答社区
MLink问答社区
Jonic问答社区
Jike问答社区
16892问答社区
Vigges问答社区
55276问答社区
OGeek问答社区
深圳家问答社区
深圳家问答社区
深圳家问答社区
Vigges问答社区
Vigges问答社区
在这了问答社区
DevDocs API Documentations
Xstack问答社区
生活宝问答社区
OverStack问答社区
Ostack问答社区
在这了问答社区
在哪了问答社区
Xstack问答社区
无极谷问答社区
TouSu问答社区
SQlite问答社区
Qi-U问答社区
MLink问答社区
Jonic问答社区
Jike问答社区
16892问答社区
Vigges问答社区
55276问答社区
OGeek问答社区
深圳家问答社区
深圳家问答社区
深圳家问答社区
Vigges问答社区
Vigges问答社区
在这了问答社区
在这了问答社区
DevDocs API Documentations
Xstack问答社区
生活宝问答社区
OverStack问答社区
Ostack问答社区
在这了问答社区
在哪了问答社区
Xstack问答社区
无极谷问答社区
TouSu问答社区
SQlite问答社区
Qi-U问答社区
MLink问答社区
Jonic问答社区
Jike问答社区
16892问答社区
Vigges问答社区
55276问答社区
OGeek问答社区
深圳家问答社区
深圳家问答社区
深圳家问答社区
Vigges问答社区
Vigges问答社区
在这了问答社区
DevDocs API Documentations
广告位招租
...