rust Questions
3
Solved
Rust supports trait inheritance, as follows:
pub trait A {}
pub trait B: A {}
B: A means that if some type T implements B, it also needs to implement all the methods in A.
But today I see the foll...
1
Solved
If you create a function returning an impl Trait which requires a lifetime that can't be elided, rustc tells you to add it.
use futures::prelude::*;
fn make_fut(input: &()) -> impl Future&l...
Starofbethlehem asked 27/10 at 0:17
2
Here's the code:
use std::thread;
use std::sync::mpsc;
fn main() {
//spawn threads
let (tx, rx) = mpsc::channel();
for mut i in 0 .. 10 {
let txc = tx.clone(); //clone from the main sender
...
Derron asked 22/4, 2020 at 12:17
2
I'm trying to deserialize MathML using Serde and Quick-XML in Rust. I'm having trouble trying to write the structs because of the recursive nature of MathML. Here's a minimal, reproducible example:...
Communard asked 11/6, 2021 at 7:3
2
Solved
I am using the below code to insert to a Postgres DB using tokio-postgres, is there any better option :
let members = &[obj] //obj is a struct
let mut params = Vec::<&(dyn ToSql + Sync)&...
Anthracosilicosis asked 30/3, 2022 at 22:3
2
In rust, is there a version of f32 / f64 that implements Eq?
The only reason I can see for f32 / f64 not implementing Eq is that NaN != NaN.
Potential ways such a type could behave:
The type could...
Chon asked 18/8, 2022 at 20:50
4
Solved
Suppose I've got
use polars::prelude::*;
pub struct Person {
id: u32,
name: String,
age: u32,
}
let df = df!(
"id" => &[1,2,3],
"name" => &["John"...
Kessler asked 20/2 at 20:4
2
Solved
I am trying to iterate over each row of a Polars rust dataframe.
In this endeavour, I have found df.get but the documentation says that this is slow. Then I have tried df.column("col").ge...
Protector asked 30/5, 2022 at 21:59
1
I'm trying to display a local time using postgres-rs, with time-rs 0.3 instead of chrono-rs 0.4. But with the timezone set to Europe/Amsterdam, all I get is UTC timestamps with no timezone informat...
Hoashis asked 1/10 at 8:45
5
I'd like to apply a user-define function which takes a few inputs (corresponding some columns in a polars DataFrame) to some columns of a polars DataFrame in Rust. The pattern that I'm using is as ...
Cid asked 25/5, 2022 at 6:27
2
Solved
I'm working on verifying some Rust code using SAW. SAW requires that you compile to LLVM bitcode, which you can then import and verify. I know you can generate bitcode using the --emit=llvm-bc flag...
Riband asked 3/9, 2021 at 8:48
2
Solved
Given something like this:
struct Example {
a: i32,
b: String,
}
Is there any built-in method or any trait I can implement that will allow me to obtain a tuple of (i32, String)?
Jud asked 7/11, 2018 at 17:3
1
Solved
I am encountering a puzzling error when creating a tuple-like struct somewhere in my Rust project.
The error
I boiled my issue down to the following snippet:
mod parent {
pub struct X(u32);
mod ...
Oe asked 17/9 at 11:20
1
I have written a small executable to start a WebSocket server for a Node development environment.
In a separate NodeJS application (running in Electron), I am using child_process.spawn() to run the...
1
Consider the following situation, with two Traits. The first Trait is for pointer types, and the second Trait is for regular objects. The second trait has a HRTB so that any reference to a type tha...
Prophesy asked 5/1, 2021 at 5:21
1
Solved
If I try to build the following code:
fn main () {
let my_val: u32 = 42;
match my_val % 2 {
0 => println!("We're even now"),
1 => println!("Well, that's odd"),
}
}
...
Berl asked 11/9 at 9:11
0
I can't figure out why I need a 'static bound in one case (bar) and not the other (baz):
fn f<T>(_input: T) -> bool {
false
}
fn bar<T>() -> Box<dyn Fn(T) -> bool + 'stati...
3
Solved
I am trying to make a get request to a url with rust and everytime I run this project I get this error, my other rust project work fine.
here's my cargo.toml file.
[package]
name = "api_req&qu...
Juju asked 25/5, 2022 at 16:39
1
Solved
The Vectorcall protocol is a new calling convention for Python's C API defined in PEP 590. The idea is to speed up calls in Python by avoiding the need to build intermediate tuples and dicts, and i...
Dna asked 25/8 at 20:35
3
I don't know how to fix this error (for pip install transformer on windows):
error: can't find Rust compiler
If you are using an outdated pip version, it is possible a prebuilt wheel is available f...
3
Solved
I would like to pass in the parameters what arm of the enum I need to match, something like this:
enum D {
A(i64),
B(u64),
C(u64, u64),
}
let a = D.A(10);
println!(a.is_of(D.A)); // true
prin...
3
When I run cargo install cargo-binutils, I get the below error. I have gcc installed and in my path, to the point where where gcc correctly returns the location.
gcc version: gcc.exe (i686-posix-...
Francinefrancis asked 6/5, 2020 at 21:44
1
I ran into the kind of a problem described in this question: How can I create a Tokio runtime inside another Tokio runtime without getting the error "Cannot start a runtime from within a runti...
Photodrama asked 27/10, 2021 at 9:23
1
Consider the following rust program:
fn f<'a>(x: &'a i32) {
unimplemented!();
}
fn main() {
f::<'static>;
}
When compiling it, the following compilation error is outputed:
error...
3
Solved
I'm using polars and I would like to define the type of the columns while loading a dataframe. In pandas, I can use dtype:
df=pd.read_csv("iris.csv", dtype={'petal_length':str})
I'm tryi...
Lockhart asked 16/4, 2021 at 17:14
1 Next >
© 2022 - 2024 — McMap. All rights reserved.