Skip to content

Commit

Permalink
Merge pull request #231 from rruckley/bug-derivepanic-228
Browse files Browse the repository at this point in the history
Bug: Remove panic for derive macros
  • Loading branch information
rruckley authored Jan 29, 2025
2 parents 0f10ed2 + eab95be commit 56790b1
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 10 deletions.
7 changes: 2 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[workspace]
allow_dirty = true

[package]
name = "tmflib"
version = "0.1.26"
Expand Down Expand Up @@ -219,8 +216,8 @@ serde = { version = "1.0.217", features = ["derive"]}
serde_json = "1.0.138"
sha256 = { version = "1.5", default-features = false }
uuid = { version = "1.12.1", features = ["v4"]}
tmflib-derive = { version = "0.1.30" }
# tmflib-derive = { path = "tmflib-derive"}
# tmflib-derive = { version = "0.1.30" }
tmflib-derive = { path = "tmflib-derive"}
hex = "0.4.3"
base32 = "0.5.1"
openapiv3 = "2.0.0"
Expand Down
8 changes: 8 additions & 0 deletions src/tmf629/customer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,5 +429,13 @@ mod test {
assert_eq!(segment.is_some(),true);
assert_eq!(segment.unwrap(),CUSTOMER_SEGMENT);
}

#[test]
fn test_customer_noid() {
let customer = Customer::default();

assert_eq!(customer.get_id(),String::default());
assert_eq!(customer.get_href(),String::default());
}
}

2 changes: 1 addition & 1 deletion tmflib-derive/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tmflib-derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[package]
name = "tmflib-derive"
version = "0.1.30"
version = "0.1.31"
edition = "2021"
authors = ["Ryan Ruckley <[email protected]>"]
description = "Derive macro for the tmflib::HasId trait"
Expand Down
12 changes: 9 additions & 3 deletions tmflib-derive/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright [2024] [Ryan Ruckley]
// Copyright [2025] [Ryan Ruckley]

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -53,10 +53,16 @@ pub fn hasid_derive(input: TokenStream) -> TokenStream {
self.href = href.into();
}
fn get_id(&self) -> String {
self.id.as_ref().unwrap().clone()
match self.id.as_ref() {
Some(i) => i.clone(),
None => String::default(),
}
}
fn get_href(&self) -> String {
self.href.as_ref().unwrap().clone()
match self.href.as_ref() {
Some(h) => h.clone(),
None => String::default(),
}
}
fn get_class() -> String {
CLASS_PATH.to_string()
Expand Down

0 comments on commit 56790b1

Please sign in to comment.