nu_protocol/value/
glob.rs1use serde::Deserialize;
2use std::fmt::Display;
3
4#[derive(Debug, Clone, Deserialize)]
7pub enum NuGlob {
8 DoNotExpand(String),
11 Expand(String),
14}
15
16impl NuGlob {
17 pub fn strip_ansi_string_unlikely(self) -> Self {
18 match self {
19 NuGlob::DoNotExpand(s) => NuGlob::DoNotExpand(nu_utils::strip_ansi_string_unlikely(s)),
20 NuGlob::Expand(s) => NuGlob::Expand(nu_utils::strip_ansi_string_unlikely(s)),
21 }
22 }
23
24 pub fn is_expand(&self) -> bool {
25 matches!(self, NuGlob::Expand(..))
26 }
27}
28
29impl AsRef<str> for NuGlob {
30 fn as_ref(&self) -> &str {
31 match self {
32 NuGlob::DoNotExpand(s) | NuGlob::Expand(s) => s,
33 }
34 }
35}
36
37impl Display for NuGlob {
38 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
39 write!(f, "{}", self.as_ref())
40 }
41}