# hooks.SparseValues

- **Module:** hooks
- **Package:** libtmux
- **Language:** Rust
- **Kind:** struct
- **Source:** https://github.com/libtmux/libtmux-rs/blob/f0e37052c232636b61d095817046e6bfc8f2ca40/crates/libtmux/src/hooks.rs#L50
- **Page:** https://libtmux.org/en/rs/latest/reference/hooks-sparsevalues/

The values one array option holds, by the index tmux stores them under.

Indices are sparse, and tmux means it. Setting a value without an index
writes slot `0`, removing one slot of several leaves the rest where they
were, and nothing renumbers, so a `SparseValues` with two entries may hold
them at `0` and `30`. Iteration is by ascending index.

## Example

```rust
let guard = libtmux::test::TestServer::new().await?;
let server = guard.server();

server.set_hook("after-new-window", "display-message built").await?;
let hooks = server.hook("after-new-window").await?.expect("the hook is set");

assert_eq!(hooks.len(), 1);
assert_eq!(
    hooks.first().map(|value| value.to_string_lossy().into_owned()),
    Some("display-message built".to_owned()),
);

guard.shutdown().await?;
```

## Members

- `get` (method): The value stored at one index.
- `first` (method): The value at the lowest index, which is what a write without one sets.
- `len` (method): How many values this option holds.
- `is_empty` (method): Whether this option holds nothing.
- `iter` (method): The values and the indices they are stored under, lowest first.
- `indices` (method): The indices that hold a value, ascending.
- `values` (method): The values alone, by ascending index.
- `into_values` (method): The values alone, owned, by ascending index.
