-
Notifications
You must be signed in to change notification settings - Fork 47
Closed
Description
Another use case to take into account while the model phase of #113 is taking shape.....
This is also related to the #134 use case, but not limited to:
- aiding a new/infrequent user quickly get useful data to assist with debugging.
- 'tracing' the LHS of the expression where the function is in a sealed trait or 3rd-party crate.
The following should be possible (initially sync only):
#[trace(variables=[p, n]]
fn factorial(mut n: u64) -> u64 {
let mut p = 1;
while n > 1 {
p *= n;
n -= 1;
}
p
}
The idea would be to have this become (better suggestions welcome):
fn factorial(mut n: u64) -> u64 {
let _g = LocalSpan::enter_with_local_parent();
let mut p;
{
let _mt = LocalSpan::enter_with_local_parent();
p = 1;
}
while n > 1 {
{
let _mt = LocalSpan::enter_with_local_parent();
p *= n;
}
{
let _mt = LocalSpan::enter_with_local_parent();
n -= 1;
}
}
p
}
Producing SpanRecords for:
- p = 1
- p = 8
- n = 7
- p = 56
- n = 6
Metadata
Metadata
Assignees
Labels
No labels