you are viewing a single comment's thread
view the rest of the comments
[–] 6 points 2 years ago* (3 children)

Do you mind explaining? Maybe with the context of another languages equivalent?

  • source
  • parent
  • hideshow 6 child comments
  • [–] 12 points 2 years ago (2 children)
    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
    });
    
  • source
  • parent
  • hideshow 4 child comments
  • [–] 1 point 2 years ago*

    it's just a way to use map with a reference instead of the value, by what I understood.

    could be usefull for logging values in a Result so you can see it. However I think you can already do that by just mapping and returning the variable.

  • source
  • parent