Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
32 views

I'm working on a tauri application, Fluster. I'm trying to add a method to parse general tabular data using polars, and then return that data as a vec of hashmaps. I'm currently running into this ...
Fluster.IO's user avatar
1 vote
1 answer
101 views

Let's say I have a function that knows how to poll a no-result future in a way specific to my environment: /// Poll the supplied future in some special way until it becomes ready. fn poll_until_ready&...
jacobsa's user avatar
  • 7,817
0 votes
0 answers
50 views

There is a trait defined for error response which has all error codes but for few resources I want to update a separate error response for few error codes like 400,403. I defined the 400 error data ...
Uday's user avatar
  • 19
2 votes
1 answer
96 views

I've implemented a Rust clone of bgpdump that displays MRT messages in the same format as bgpdump. To print the message, I implemented the Display trait and printed it to stdout. However, I'm ...
vgauthier's user avatar
-3 votes
1 answer
97 views

I am implementing a function in Rust that take a callback function as an argument. As far as I learned, I can use Fn trait bound to do that. But now I want this callback function to be async, and I ...
yijiecc's user avatar
  • 23
0 votes
1 answer
71 views

So I have a struct WeatherStation which consists of a name: String and probability distribution function which should implement the rand::distr::Distribution trait. It look something like this: struct ...
7tzvD's user avatar
  • 13
2 votes
1 answer
90 views

I have the following code. The compiler complains about the last line. I am wondering why. The WrappedFunction case class takes a function object with trait arguments. When I try to construct a ...
user3068137's user avatar
0 votes
0 answers
62 views

When writing a function that should be able to operate on any Diesel selectable table, for example something like "is this table empty", what is the correct way to specify the trait bound? I ...
goose_lake's user avatar
  • 1,627
0 votes
1 answer
79 views

I'm writing a library that deals with numerical attributes. For this I have created a trait for all the number primitives: trait Sealed {} #[allow(private_bounds, reason = "To seal trait Number&...
Levente Bokor's user avatar
1 vote
1 answer
152 views

Reading the Rust book and struggling to understand why I should use traits over methods if I still need to write an implementation of the trait for each object that can have that trait. Apart from the ...
Heiko's user avatar
  • 75
1 vote
0 answers
57 views

I have this trait HasExtendedRoles.php trait HasExtendedRoles { use HasRoles; use HasExtendedPermissions { HasExtendedPermissions::getPermissionClass insteadof HasRoles; ...
3m1n3nc3's user avatar
  • 586
5 votes
2 answers
163 views

Here is the code, I'm trying to make bounded floating point numbers. I do this with a Bounds trait, that must be implemented for the generic type B in the Bounded number struct. I would like to be ...
Tommaso Clini's user avatar
0 votes
1 answer
88 views

I have a Trait called HasDefault its main purpose is to ensure that the class has a static field $default which is callable and returns the default instance of the class using the Trait This is what ...
LordF's user avatar
  • 536
0 votes
0 answers
19 views

So, at the moment, I'm implementing a matrix. This fn multiply<const P: usize, T>(&self, rhs: T) -> Matrix<R, P> where T: AsRef<Matrix<C, P>>, is the signature of ...
minomy13's user avatar
  • 130
1 vote
1 answer
1k views

While implementing a handler function for an Axum endpoint, I ran accross the following error --> qubic-rpc/src/lib.rs:90:38 | 90 | .route("/balances/{id}", get(routes::...
gmelodie's user avatar
  • 492
0 votes
1 answer
46 views

The signatures for Sender::send and JoinHandle::join are, respectively: pub fn send(&self, t: T) -> Result<(), SendError<T>> pub fn join(self) -> Result<T, Box<dyn Any + ...
twig-froth's user avatar
5 votes
1 answer
66 views

I'm trying to make a zero cost abstraction library that adds units to values, to ensure computations homogeneity at compile time. The core type is: pub struct QuantifiedValue<T, U: Unit> { ...
LucioleMaléfique's user avatar
0 votes
1 answer
46 views

I want to create types, and implementations of std::ops::Add such that: add(Position, Displacement) -> Position add(Displacement, Displacement) -> Displacement The purpose is to make nonsense ...
fadedbee's user avatar
  • 45.2k
0 votes
0 answers
76 views

This code (derived from a more complex example) compiles [playground]: fn func1<'a>(s: &'a str) where 'static: 'a { println!("{s}"); } fn func2<'a>(s: &'a str) { func1(s)...
FreD's user avatar
  • 502
1 vote
1 answer
50 views

I have a trait Input that adds a to_custom_bytes() method to Strings and u64s. trait Input { fn to_custom_bytes(&self) -> Vec<u8>; } impl Input for u64 { fn to_custom_bytes(&...
mikemaccana's user avatar
0 votes
3 answers
161 views

In Rust, there is no type for functions, but rather an Fn trait that looks something like this: trait Fn<A: Tuple, R> { fn call(self, args: A) -> R; } Then the type of a function can be ...
דניאל פ.ח.'s user avatar
1 vote
0 answers
40 views

Suppose I we want to flatten vectors: [0, 50, 100] -> [0, 50, 100] [[0], [50, 50], 100] -> [0, 50, 50, 100] [[[0]]] -> [0] We can define a trait such as pub trait FlattenVec<A> { ...
Bhavye Mathur's user avatar
2 votes
1 answer
157 views

Say that I have the following trait: trait SayHello { fn say_hello(self) -> String; } Why can I then do this: fn say_hello_twice(this: impl SayHello) -> String { let said_hello = this....
דניאל פ.ח.'s user avatar
0 votes
0 answers
46 views

I'm trying to write a blanket implementation of a trait for types that are another trait with a specific associated type. That is, it is fully permissible to do this: use std::{marker::PhantomData, ...
Benjie's user avatar
  • 138
0 votes
0 answers
48 views

I am trying to learn some Rust by creating a neural network from scratch. I started by defining a Matrix struct using const generics in order to check for matrix size at compile time when performing ...
Chell's user avatar
  • 1

1
2 3 4 5
73