Skip to content

Commit

Permalink
feat: tree::EntryMode::as_str() to display itself as a string. (#427)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Aug 3, 2022
1 parent c5846e0 commit 4f4bba2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions git-object/src/tree/mod.rs
Expand Up @@ -38,6 +38,18 @@ impl EntryMode {
pub fn is_no_tree(&self) -> bool {
*self != EntryMode::Tree
}

/// Represent the mode as descriptive string.
pub fn as_str(&self) -> &'static str {
use EntryMode::*;
match self {
Tree => "tree",
Blob => "blob",
BlobExecutable => "exe",
Link => "link",
Commit => "commit",
}
}
}

/// An element of a [`TreeRef`][crate::TreeRef::entries].
Expand Down

0 comments on commit 4f4bba2

Please sign in to comment.