Skip to main content
Stack Overflow
  1. About
  2. For Teams
Filter by
Sorted by
Tagged with
Best practices
0 votes
2 replies
95 views

Is there a way that I can have a reference to a variable while allowing that variable to be mutated in Rust, so long as I "pinky promise not to access the data of the stored variable" so ...
3 votes
1 answer
80 views

The Rust compiler gives me a lifetime error with the following code (which is a minimal working example of some real code): pub trait TElement: Copy { // Details irrelevant } pub trait TSet<'a,...
5 votes
2 answers
149 views

This is a pattern I want to be able to use in my code to have global variables that contain non-static references. Is it memory safe? If not, how can I make it so? use std::cell::Cell; pub struct ...
11 votes
1 answer
601 views

The signature of std::thread::Scope::spawn looks like this: pub fn spawn<F, T>(&'scope self, f: F) -> ScopedJoinHandle<'scope, T> where F: FnOnce() -> T + Send + 'scope, ...
jacobsa's user avatar
  • 7,905
Best practices
0 votes
3 replies
67 views

Our application is somewhat of a middleman that transforms data from numerous APIs. Initially to simplify things, we wrote a bunch of specific clients which wrap an instance of HttpClient created in ...
3 votes
1 answer
139 views

While trying to convince myself precisely why this code in std::thread::Scope works, I hit upon the following problem. Below is a struct that accepts two lifetime parameters, and a pair of functions ...
jacobsa's user avatar
  • 7,905
0 votes
1 answer
58 views

Using default code from lifelines.datasets import load_dd data = load_dd() kmf = KaplanMeierFitter() kmf.fit(data["duration"], event_observed=data["observed"]) kmf....
5 votes
1 answer
138 views

I am using the winnow crate to write a parser and am struggling with adding tests due to lifetime conflicts. The basic setup I have is a stateful stream: // The primary stream type type SStream<'i, ...
5 votes
0 answers
94 views

I noticed that destructors (Drop) in async functions don’t always execute in the same order when nested awaits are used. struct Guard(&'static str); impl Drop for Guard { fn drop(&mut self) { ...
0 votes
1 answer
145 views

After reading this, I got an idea, What if I make g_map a const reference, which should extend the life time of the temporary object. So it can be valid until end of main function. But it seems that ...
0 votes
2 answers
166 views

In order to examine object representation, the C++ standard provides https://timsong-cpp.github.io/cppwp/n4861/basic.lval#11: If a program attempts to access ([defns.access]) the stored value of an ...
1 vote
1 answer
120 views

I'm aware it is not much possible nor recommended to have both a field that owns a value, and another one that stores a reference to the same value in a struct. I was experimenting a bit with a more ...
21 votes
2 answers
541 views

Just stumble across Why we didn't rewrite our feed handler in Rust from databento And they say they cannot share a buffer during a loop. What would be the rust way to fix this without making copies of ...
11 votes
1 answer
168 views

I'm developing a rust crate that abstracts audio buffers. A key challenge are non continuous slices. My solution to those is the MutableView, it's supposed to remap a continuous index to a non ...
14 votes
1 answer
487 views

In Rust, the object Box<dyn Any> has a default life time of 'static. The compiler seems to accept using a different lifetime, for example Box<dyn Any + 'short>. However, this causes a ...

15 30 50 per page
1
2 3 4 5
...
187

AltStyle によって変換されたページ (->オリジナル) /