"Fossies" - the Fresh Open Source Software Archive

Member "fd-8.1.1/src/exec/token.rs" (25 May 2020, 878 Bytes) of package /linux/privat/fd-8.1.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Rust source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "token.rs": 7.5.0_vs_8.0.0.

    1 use std::fmt::{self, Display, Formatter};
    2 
    3 /// Designates what should be written to a buffer
    4 ///
    5 /// Each `Token` contains either text, or a placeholder variant, which will be used to generate
    6 /// commands after all tokens for a given command template have been collected.
    7 #[derive(Clone, Debug, PartialEq)]
    8 pub enum Token {
    9     Placeholder,
   10     Basename,
   11     Parent,
   12     NoExt,
   13     BasenameNoExt,
   14     Text(String),
   15 }
   16 
   17 impl 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 }