tmux_interface/options/common/user_option/
set_user_option.rs

1use crate::options::{SetOptionTr, USER_OPTION_MARKER};
2use crate::TmuxCommand;
3use std::borrow::Cow;
4
5pub trait SetUserOption: SetOptionTr {
6    fn user_option<'a, S, T>(name: S, value: Option<T>) -> TmuxCommand<'a>
7    where
8        S: Into<Cow<'a, str>>,
9        T: Into<Cow<'a, str>>,
10    {
11        Self::set(format!("{}{}", USER_OPTION_MARKER, name.into()), value)
12    }
13
14    /// # Manual
15    ///
16    /// ```text
17    /// @user-option-name value
18    /// ```
19    fn user_option_ext<'a, U, S, T>(target: Option<U>, name: S, value: Option<T>) -> TmuxCommand<'a>
20    where
21        U: Into<Cow<'a, str>>,
22        S: Into<Cow<'a, str>>,
23        T: Into<Cow<'a, str>>,
24    {
25        Self::set_ext(
26            target,
27            format!("{}{}", USER_OPTION_MARKER, name.into()),
28            value,
29        )
30    }
31}