OxL Reference

method span.with

Runs body inside a span named name; the span ends when body returns or fails.

Example:

oxl✓ checked in CI
use std.obs { span }

fn main() io {
  let total = span.with("sum") {
    var t = 0
    for i in 1..=10 { t += i }
    t
  }
  print("{total}")
}
Output
55
pub(api) static fn with<T, effect F>(name: str, body: fn() -> T F) -> T  F

Complexity. O(1) overhead; a no-op when tracing is off.

Since. 1.0.0-beta

Parameters

NameType
namestr
bodyfn() -> T F

Returns

T F

Effects

none declared (pure unless the body says otherwise)

Defined in: std/obs/obs.oxl:465

See also