summaryrefslogtreecommitdiff
path: root/src/chunkid.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/chunkid.rs')
-rw-r--r--src/chunkid.rs8
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))
}
}