summaryrefslogtreecommitdiffstats
path: root/vendor/gix-attributes/src/assignment.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/gix-attributes/src/assignment.rs')
-rw-r--r--vendor/gix-attributes/src/assignment.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/vendor/gix-attributes/src/assignment.rs b/vendor/gix-attributes/src/assignment.rs
index e1d7263f7..87689d443 100644
--- a/vendor/gix-attributes/src/assignment.rs
+++ b/vendor/gix-attributes/src/assignment.rs
@@ -1,4 +1,6 @@
use crate::{Assignment, AssignmentRef, NameRef, StateRef};
+use bstr::ByteSlice;
+use std::fmt::Write;
impl<'a> AssignmentRef<'a> {
pub(crate) fn new(name: NameRef<'a>, state: StateRef<'a>) -> AssignmentRef<'a> {
@@ -26,3 +28,24 @@ impl<'a> Assignment {
AssignmentRef::new(self.name.as_ref(), self.state.as_ref())
}
}
+
+impl std::fmt::Display for AssignmentRef<'_> {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ match self.state {
+ StateRef::Set => f.write_str(self.name.as_str()),
+ StateRef::Unset => {
+ f.write_char('-')?;
+ f.write_str(self.name.as_str())
+ }
+ StateRef::Value(v) => {
+ f.write_str(self.name.as_str())?;
+ f.write_char('=')?;
+ f.write_str(v.as_bstr().to_str_lossy().as_ref())
+ }
+ StateRef::Unspecified => {
+ f.write_char('!')?;
+ f.write_str(self.name.as_str())
+ }
+ }
+ }
+}