Create a separator from a byte slice. Optimizes for common cases: - Single `\n` → `Separator::Newline` - `\r\n` → `Separator::CrLf` - Single byte → `Separator::Byte` - Otherwise → `Separator::Custom`
(bytes: &[u8])
| 73 | /// - Single byte → `Separator::Byte` |
| 74 | /// - Otherwise → `Separator::Custom` |
| 75 | pub fn from_bytes(bytes: &[u8]) -> Self { |
| 76 | match bytes { |
| 77 | b"\n" => Separator::Newline, |
| 78 | b"\r\n" => Separator::CrLf, |
| 79 | [b] => Separator::Byte(*b), |
| 80 | _ => Separator::Custom(bytes.to_vec()), |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | /// Get the separator as a byte slice. |
| 85 | pub fn as_bytes(&self) -> &[u8] { |
nothing calls this directly
no outgoing calls
no test coverage detected