MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / from_bytes

Method from_bytes

atomic-core/src/diff/split.rs:75–82  ·  view source on GitHub ↗

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])

Source from the content-addressed store, hash-verified

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] {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected