# error.scoped.ScopeError.into_value

- **Module:** error.scoped.ScopeError
- **Package:** libtmux
- **Language:** Rust
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-rs/blob/f0e37052c232636b61d095817046e6bfc8f2ca40/crates/libtmux/src/error/scoped.rs#L121
- **Page:** https://libtmux.org/en/rs/latest/reference/error-scoped-scopeerror-into_value/

```
error.scoped.ScopeError.into_value(self) -> Option<T>
```

Take the value the operation produced before cleanup failed.

`None` unless the operation succeeded, which is the one case where a
result would otherwise be lost: the outer `Result` is `Err` either way.

## Example

```rust
// The work is done even when tearing the session down failed, so the
// value is worth keeping rather than discarding with the error.
let outcome = server
    .with_session("build", async |session| {
        Ok::<_, libtmux::Error>(session.id().to_string())
    })
    .await;

let id = match outcome {
    Ok(id) => Some(id),
    Err(error) => error.into_value(),
};
```
