Skip to content

Commit 8dbf8a9

Browse files
committed
Type::short is an implementation detail of to_string, move it back there.
1 parent e53d863 commit 8dbf8a9

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

src/lib.rs

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,6 @@ impl Type {
7878
_ => Unknown,
7979
}
8080
}
81-
82-
fn short(self) -> char {
83-
use Type::*;
84-
match self {
85-
Fifo => 'p',
86-
CharDevice => 'c',
87-
Dir => 'd',
88-
BlockDevice => 'b',
89-
File => '-',
90-
Symlink => 'l',
91-
Socket => 's',
92-
Whiteout => 'w',
93-
Unknown => '?',
94-
}
95-
}
9681
}
9782

9883
/// Enum for specifying the context / "who" accesses in [is_allowed]
@@ -217,15 +202,26 @@ pub fn is_sticky(mode: u32) -> bool {
217202
pub fn to_string(mode: u32) -> String {
218203
// This is decoded "by hand" here so that it'll work
219204
// on non-Unix platforms.
205+
use Access::*;
206+
use Accessor::*;
207+
use Type::*;
220208

221209
let setuid = is_setuid(mode);
222210
let setgid = is_setgid(mode);
223211
let sticky = is_sticky(mode);
224212

225213
let mut s = String::with_capacity(10);
226-
s.push(Type::from(mode).short());
227-
use Access::*;
228-
use Accessor::*;
214+
s.push(match Type::from(mode) {
215+
Fifo => 'p',
216+
CharDevice => 'c',
217+
Dir => 'd',
218+
BlockDevice => 'b',
219+
File => '-',
220+
Symlink => 'l',
221+
Socket => 's',
222+
Whiteout => 'w',
223+
Unknown => '?',
224+
});
229225
for accessor in [User, Group, Other] {
230226
for access in [Read, Write, Execute] {
231227
s.push(

0 commit comments

Comments
 (0)