pxar: simplify MatchPattern::to_bytes
This commit is contained in:
parent
e50a90e010
commit
920243b12d
@ -222,23 +222,9 @@ impl MatchPattern {
|
|||||||
pub fn to_bytes(patterns: &[MatchPattern]) -> Vec<u8> {
|
pub fn to_bytes(patterns: &[MatchPattern]) -> Vec<u8> {
|
||||||
let mut buffer = Vec::new();
|
let mut buffer = Vec::new();
|
||||||
for pattern in patterns {
|
for pattern in patterns {
|
||||||
let byte_pattern = pattern.pattern.as_bytes();
|
if !pattern.match_positive { buffer.push(b'!'); }
|
||||||
match (pattern.match_positive, pattern.match_dir_only) {
|
buffer.extend_from_slice( pattern.pattern.as_bytes());
|
||||||
(true, true) => {
|
if pattern.match_dir_only { buffer.push(b'/'); }
|
||||||
buffer.extend_from_slice(byte_pattern);
|
|
||||||
buffer.push(b'/');
|
|
||||||
}
|
|
||||||
(true, false) => buffer.extend_from_slice(byte_pattern),
|
|
||||||
(false, true) => {
|
|
||||||
buffer.push(b'!');
|
|
||||||
buffer.extend_from_slice(byte_pattern);
|
|
||||||
buffer.push(b'/');
|
|
||||||
}
|
|
||||||
(false, false) => {
|
|
||||||
buffer.push(b'!');
|
|
||||||
buffer.extend_from_slice(byte_pattern);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
buffer.push(b'\n');
|
buffer.push(b'\n');
|
||||||
}
|
}
|
||||||
buffer
|
buffer
|
||||||
|
Loading…
Reference in New Issue
Block a user