• @[email protected]
    link
    fedilink
    English
    135 months ago
    let bar: Result<T, E> = ...;
    let foo = bar.inspect(|value| log::debug("{}", value));
    

    is equivalent to

    let bar: Result<T, E> = ...;
    let foo = bar.map(|value| {
        log::debug("{}", value);
        value
    });
    
    • @xav
      link
      15 months ago

      Warning: in the first case “value” is actually a shared reference, not a value.

    • λλλ
      link
      15 months ago

      Elegant. Thanks!