Skip to content

Commit

Permalink
change Signature::name() to Option<String>
Browse files Browse the repository at this point in the history
  • Loading branch information
ctb committed Dec 17, 2024
1 parent 0f006e1 commit 34dba54
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/core/src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl Record {
Self {
internal_location: path.into(),
moltype: moltype.to_string(),
name: sig.name(),
name: sig.name().unwrap_or("".into()),
ksize,
md5,
md5short,
Expand Down
8 changes: 4 additions & 4 deletions src/core/src/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,11 +445,11 @@ fn default_version() -> f64 {
}

impl Signature {
pub fn name(&self) -> String {
pub fn name(&self) -> Option<String> {
if let Some(name) = &self.name {

Check failure on line 449 in src/core/src/signature.rs

View workflow job for this annotation

GitHub Actions / Lints (beta)

manual implementation of `Option::map`

Check failure on line 449 in src/core/src/signature.rs

View workflow job for this annotation

GitHub Actions / Lints (stable)

manual implementation of `Option::map`
name.clone()
Some(name.clone())
} else {
"".into()
None
}
}

Expand Down Expand Up @@ -981,7 +981,7 @@ mod test {
assert_eq!(sig.signatures[1].size(), 2);
assert_eq!(sig.signatures[2].size(), 1);

assert_eq!(sig.name(), "");
assert_eq!(sig.name().unwrap_or("".into()), "");
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions src/core/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ impl ZipStorage {

impl SigStore {
pub fn new_with_storage(sig: Signature, storage: InnerStorage) -> Self {
let name = sig.name();
let name = sig.name().unwrap_or("".into());
let filename = sig.filename();

SigStore::builder()
Expand Down Expand Up @@ -555,7 +555,7 @@ impl Deref for SigStore {

impl From<Signature> for SigStore {
fn from(other: Signature) -> SigStore {
let name = other.name();
let name = other.name().unwrap_or("".into());
let filename = other.filename();

SigStore::builder()
Expand Down
2 changes: 1 addition & 1 deletion src/core/tests/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ fn innerstorage_save_sig() -> Result<(), Box<dyn std::error::Error>> {

let loaded_sig = instorage.load_sig("test")?;

assert_eq!(sig.name(), loaded_sig.name());
assert_eq!(sig.name().unwrap_or("".into()), loaded_sig.name());
assert_eq!(sig.md5sum(), loaded_sig.md5sum());

Ok(())
Expand Down

0 comments on commit 34dba54

Please sign in to comment.