diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-01-04 18:03:04 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-01-04 18:03:04 +0000 |
commit | 678e65c57ae983ef66d16e92965814b0f3f0d73f (patch) | |
tree | 260f2edd09047de5843a168ce59f284ac3445ce7 /src/chunkid.rs | |
parent | 6c00201a0aaf75071388981591d76bebdc7b1f03 (diff) | |
parent | 34a9fc7cf754552b02b194f7e1186adc9414a623 (diff) | |
download | obnam2-678e65c57ae983ef66d16e92965814b0f3f0d73f.tar.gz |
Merge branch 'checksum' into 'main'
Checksum
See merge request larswirzenius/obnam!61
Diffstat (limited to 'src/chunkid.rs')
-rw-r--r-- | src/chunkid.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/chunkid.rs b/src/chunkid.rs index 9eec41f..3933d4b 100644 --- a/src/chunkid.rs +++ b/src/chunkid.rs @@ -37,6 +37,10 @@ impl ChunkId { } } + pub fn from_str(s: &str) -> Self { + ChunkId { id: s.to_string() } + } + pub fn as_bytes(&self) -> &[u8] { self.id.as_bytes() } @@ -81,7 +85,7 @@ impl FromStr for ChunkId { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - Ok(ChunkId { id: s.to_string() }) + Ok(ChunkId::from_str(s)) } } @@ -113,6 +117,6 @@ mod test { fn survives_round_trip() { let id = ChunkId::new(); let id_str = id.to_string(); - assert_eq!(id, id_str.parse().unwrap()); + assert_eq!(id, ChunkId::from_str(&id_str)) } } |