Skip to content
Myr

token.rs

This file

Path

src/exec/token.rs

29 lines · 878 bytes · Rust

Last changed by

Remove outdated license headers (not strictly required by Apache-2.0)sharkdpbefore adoption4274075

History of this file

Take it

1use std::fmt::{self, Display, Formatter};23/// Designates what should be written to a buffer4///5/// Each `Token` contains either text, or a placeholder variant, which will be used to generate6/// commands after all tokens for a given command template have been collected.7#[derive(Clone, Debug, PartialEq)]8pub enum Token {9    Placeholder,10    Basename,11    Parent,12    NoExt,13    BasenameNoExt,14    Text(String),15}1617impl Display for Token {18    fn fmt(&self, f: &mut Formatter) -> fmt::Result {19        match *self {20            Token::Placeholder => f.write_str("{}")?,21            Token::Basename => f.write_str("{/}")?,22            Token::Parent => f.write_str("{//}")?,23            Token::NoExt => f.write_str("{.}")?,24            Token::BasenameNoExt => f.write_str("{/.}")?,25            Token::Text(ref string) => f.write_str(string)?,26        }27        Ok(())28    }29}