Questions Tagged [Rust]
Ask Question Rust Is a Systems Programming Language Without a Garbage Collector Focused on Three Goals: Safety, Speed, and Concurrency. Use This Tag for...
Rust is a systems programming language without a garbage collector focused on three goals: safety, speed, and concurrency. Use this tag for questions about code written in Rust. Use an edition specific tag for questions that refer to code which requires a particular edition, like [rust-2018]. Use more specific tags for subtopics like [rust-cargo] and [rust-macros].
28,895
questions
0
votes
0
answers
7
views
Debugging Stalled Runtime in Tokio and Rust
How do you debug code that seems to stall for no reason after running a large number of tasks?
More Detail
My code runs ~4k tasks, each:
Makes 1-100 web requests.
Parses a lot of JSON.
Returns an ...
0
votes
0
answers
11
views
Rust + Tokio: Process First Task to Complete
In Tokio, how do you wait for the first task in a list of tasks to complete? The size of the list is unknown.
More specifically:
You have a list of tasks.
Wait for the first to complete.
Run some ...
0
votes
1
answer
12
views
Best way to make async function return Vec without allocation
I need an async function return multiple items without using a future streams (i.e. futures::Stream). The most obvious way of doing that is to return Vec<T>. But I would like to avoid heap ...
-1
votes
0
answers
12
views
How to use a crate with a custom type in a rust-ink smart contract?
I want to use a byte buffer structure in a smart contract of mine.
So I want to use the bytes crate. After adding it to my Cargo.toml
file I wrote this small contract to test it out.
#![cfg_attr(not(...
0
votes
1
answer
16
views
stdweb::web::html_element::CanvasElement from document().query_selector() in Rust
I am building a Yew webapp in Rust, and attempting to get a CanvasRenderingContext2d from a CSS selector. The issue I am having is how to convert a stdweb::web::Element into a stdweb::web::...
1
vote
1
answer
27
views
Is there an alternative expression for match in Rust?
I know that when handling errors using Result and Option, it can be expressed more concisely by using unwrap_or_else, unwrap_or_default, etc. instead of match.
The following is an example of ...
0
votes
0
answers
13
views
How can implement traits for packages through rust workspace?
I created a workspace called extend_triats as lib.
[dependencies]
extend_triats = { path = "./extend_triats" }
nav_bar = { path = "./nav_bar" }
tree_list = { path = "./...
0
votes
1
answer
27
views
Mapping errors from Command::new("/bin/bash") arguments
I am executing a bash command, for which I would like to catch an error when the move argument fails. Since there is one more command after move, my goal is to capture specifically whether the move ...
-1
votes
1
answer
18
views
Rust File Tree move occurs because `subtree` has type `trees::Tree<PathBuf>`, which does not implement the `Copy` trait
i am trying to make a simple tauri Program where i have a Filetree of all Files and sub files of a chosen directory.
I have not got many experience in Rust and ran into a problem with Ownerships.
Code
...
0
votes
0
answers
15
views
Cannot run my Snap package (built from Rust App)
This is how my snapcraft.yaml looks like (at the root of my Rust project):
name: keval-snap
base: core20
version: '0.1'
summary: Single-line elevator pitch for your amazing snap # 79 char long ...
2
votes
1
answer
26
views
Copy slice into its own array
I want to copy the values at one slice of an array into another slice.
The obvious way (using iteration) is:
for i in 0..10 {
self.ram[i] = self.ram[20 + i];
}
However, that seems rather ...
1
vote
1
answer
17
views
Saving rust_decimal to mongodb
I'm trying to save a rust_decimal::Decimal object in MongoDB.
My first attempt was generally:
// self.db is of type mongodb::sync::Database
decimal = Decimal::new(1, 20);
let order = doc! {"...
0
votes
0
answers
8
views
How to query a specific set of attributes from dynamoDB using rust language?
I am new to Rust and this question may come off as silly. I am trying to develop a lambda that reads a single item from dynamoDB given a key. The returned item needs to be shared back as result to the ...
1
vote
1
answer
28
views
Is it possible to borrow different parts of self with different mutability statically?
I am designing some struct with a prepare-commit pattern in rust, which mostly looks like this after simplified:
struct Data {
a: usize,
}
struct Adder<'a> {
data: &'a mut Data,
...
0
votes
1
answer
18
views
Unexpected segfault when working with raw pointers
Initially I wrote a Heap implementation in Rust, but I was getting strange segfaults, so I narrowed down the code to this example, which reproduces the behavior.
use core::fmt::Debug;
pub struct Node&...