Questions tagged [lifetime-scoping]
97 questions
0
votes
1 answer
Not sure if I'm creating a correct lifetime scope
One of my Specflow steps is trying to use a method which takes Autofac's ILifetimeScope as a parameter. This is the method the step is trying to call:
public Client(string clientAddress, ILogger logger, IFieldDict fieldDict, IdGenerator…

runnerpaul
- 5,942
- 8
- 49
- 118
0
votes
0 answers
How to iterate over struct list with lifetime argument in Rust?
Playground
I have the following generated code (from flatbuffers schema):
pub trait TFilterData {
fn get_text(&self) -> &str;
}
pub struct Table<'a> {
pub buf: &'a [u8],
pub loc: usize,
}
pub struct Data<'a> {
pub _tab:…

4ntoine
- 19,816
- 21
- 96
- 220
0
votes
0 answers
"The type does not fulfill the required lifetime" for flatbuffers table in Rust
I have some flatbuffers IDL:
table Filter {
text: string (required);
}
which generates the following .rs:
...
pub struct Filter<'a> {
pub _tab: flatbuffers::Table<'a>,
}
...
I'm trying to add some trait impl for it:
pub trait TFilter {
fn…

4ntoine
- 19,816
- 21
- 96
- 220
0
votes
0 answers
What's the best way to wrap Redux's API so that store instances are transient instead of singletons?
I haven't had a look at the source in-depth or anything yet, but was just curious if anyone has required or made use of this in the past or not.
It appears as though Redux is creating a singleton instance for the store and persisting this for the…

Charles
- 405
- 4
- 13
0
votes
0 answers
Passing two objects, where one requires the other to be alive, but does NOT hold a reference to it, into a thread
Disclaimer: This question is very close to Passing two objects, where one holds a reference to another, into a thread, but not equal.
I have a C library which I call to get a pointer to a struct, and get a *mut ffi_context back. I then wrap that…

Benni
- 1,030
- 2
- 11
- 18
0
votes
0 answers
In Rust, I have a large number of receiver objects I'd like manage, however I'm running into lifetime issues using Select
Due to the possibility of there being a large number of objects, I'd like to have a way to add them to the select list, remove them for processing and then add them back. All, without having to rebuild the select list each time an object is added…

Bruce
- 503
- 3
- 13
0
votes
1 answer
In Rust, how to push an object with a lifetime into a vector?
I've got code somewhat like the following, which attempts to read from a websocket, parse the JSON result into a struct, and push that struct onto a Vec buffer. The code however fails to compile, because the struct has a lifetime, and the borrow…

LogicChains
- 4,332
- 2
- 18
- 27
0
votes
2 answers
How does my behave in perl when there is no any variable within the static scope?
Here is the first example:
$g=5;
sub A {
my $x=2; # $x uses static scoping
local $y=3; # $y uses dynamic soping
local $g=7;
print "In A: g=$g, x=$x, y=$y\n";
B();
}
sub B {
print "In B: g=$g, x=$x, y=$y\n";
…

BoraKurucu
- 39
- 1
- 1
- 8
0
votes
2 answers
Get Autofac Inner-most scope in WPF application
How can I get the innermost autofac scope or a named scope in a WPF application?
I need this because I use MarkupExtension to resolve VM. So in my MarkupExtension I need the current (inner-most) Lifetimescope.
Thanks

Luka
- 4,075
- 3
- 35
- 61
0
votes
0 answers
Where to store TcpStream to share with BufReader and BufWriter
I'm trying to build a simple client crate for a program that has it's own simple TCP protocol.
Most of the communication works by sending a command and immediately reading a single line response. Some of the commands need to read multiple responses.…

twe4ked
- 2,832
- 21
- 24
0
votes
2 answers
Locally owned reference considered borrowed
I've got a structural type with an Option field. Within a method on my optional type, I want to match on that field and extract the value into the local scope. I understand that I need to convince the borrow checker not to drop the memory…

Robbie McKinstry
- 3
- 1
- 1
0
votes
1 answer
Try to understand what lifetime scope means in IoC (with Autofac)?
At first I did confidentially suppose that I could understand it, but via some simple example with Autofac, it appeared that I might understand it wrong, here is the code that I've tried:
//register the…

Hopeless
- 4,397
- 5
- 37
- 64
0
votes
2 answers
How can I determine whether a variable has a scope and lifetime or not?
I understand what scope and lifetime are and how they're different:
Scope: the visibility of a variable i.e. which blocks of code can reference that variable
Lifetime: how a long a variable's value will be retained in memory
My question is: in the…
user7182612
0
votes
1 answer
The parameter type `T` may not live long enough when writing a binary searching tree
I'm trying to write a binary searching tree in Rust, but I don't understand what is going on:
enum BST<'a, T: Ord> {
Leaf,
BinTree { value: T, left: &'a mut BST<'a, T>, right: &'a mut BST<'a, T> }
}
impl<'a, T: Ord> BST<'a, T> {
fn…

Dimo Chanev
- 109
- 1
- 10
0
votes
1 answer
Implement IntoIterator for binary tree
I am trying to build a binary tree and write an iterator to traverse values in the tree.
When implementing the IntoIterator trait for my tree nodes I ran into a problem with lifetimes
src\main.rs:43:6: 43:8 error: the lifetime parameter `'a` is not…

Spencer Killen
- 3
- 1