Core Library0.xAPI Reference

Choose documentation 3

latest

Current version

latest
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

struct libtmux-rs latest

SparseValues

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

Source and package
Qualified name
libtmux::hooks::SparseValues
Module
hooks
Package
libtmux
Source
crates/libtmux/src/hooks.rs
struct hooks.SparseValues

Description#

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.

Examples#

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?;
Type parameters

Members8#

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

Guides#

Pages that discuss SparseValues.

Esc

Type to search.

Reference previewOpen reference