comparison rust/hg-core/src/revlog/node.rs @ 51700:7f0cb9ee0534

Backout accidental publication of a large range of revisions I accidentally published 25e7f9dcad0f::bd1483fd7088, this is the inverse.
author Raphaël Gomès <rgomes@octobus.net>
date Tue, 23 Jul 2024 10:02:46 +0200
parents 918ceb5a3d25
children ec7171748350
comparison
equal deleted inserted replaced
51699:bd1483fd7088 51700:7f0cb9ee0534
81 type Error = (); 81 type Error = ();
82 82
83 #[inline] 83 #[inline]
84 fn try_from(bytes: &'a [u8]) -> Result<Self, Self::Error> { 84 fn try_from(bytes: &'a [u8]) -> Result<Self, Self::Error> {
85 match Node::from_bytes(bytes) { 85 match Node::from_bytes(bytes) {
86 Ok((node, [])) => Ok(node), 86 Ok((node, rest)) if rest.is_empty() => Ok(node),
87 _ => Err(()), 87 _ => Err(()),
88 } 88 }
89 } 89 }
90 } 90 }
91 91
321 self.data == other.data && self.nybbles_len() == other.nybbles_len() 321 self.data == other.data && self.nybbles_len() == other.nybbles_len()
322 } 322 }
323 } 323 }
324 324
325 #[cfg(test)] 325 #[cfg(test)]
326 pub use tests::hex_pad_right;
327
328 #[cfg(test)]
329 mod tests { 326 mod tests {
330 use super::*; 327 use super::*;
331 328
332 const SAMPLE_NODE_HEX: &str = "0123456789abcdeffedcba9876543210deadbeef"; 329 const SAMPLE_NODE_HEX: &str = "0123456789abcdeffedcba9876543210deadbeef";
333 const SAMPLE_NODE: Node = Node { 330 const SAMPLE_NODE: Node = Node {
429 node.data[1] = 0xca; 426 node.data[1] = 0xca;
430 // now it is a prefix 427 // now it is a prefix
431 assert_eq!(prefix.first_different_nybble(&node), None); 428 assert_eq!(prefix.first_different_nybble(&node), None);
432 } 429 }
433 } 430 }
431
432 #[cfg(test)]
433 pub use tests::hex_pad_right;