Skip to content

Commit

Permalink
Keep from_value interface consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
theory committed Sep 6, 2024
1 parent 3930bb0 commit 9180f9e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/meta/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ pub struct Meta {
impl Meta {
fn from_version(version: u8, meta: Value) -> Result<Self, Box<dyn Error>> {
match version {
1 => v1::from_value(&meta),
1 => v1::from_value(meta),
2 => v2::from_value(meta),
_ => Err(Box::from(format!("Unknown meta version {version}"))),
}
Expand Down
4 changes: 2 additions & 2 deletions src/meta/v1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ pub fn to_v2(v1: &Value) -> Result<Value, Box<dyn Error>> {

/// from_value parses v1, which contains PGXN v1 metadata, into a Meta object
/// containing valid PGXN v2 metadata.
pub fn from_value(v1: &Value) -> Result<Meta, Box<dyn Error>> {
Meta::try_from(to_v2(v1)?)
pub fn from_value(v1: Value) -> Result<Meta, Box<dyn Error>> {
Meta::try_from(to_v2(&v1)?)
}

/// v1_to_v2_common sets up a new v2 map with compatible fields copied from v1
Expand Down
2 changes: 1 addition & 1 deletion src/meta/v1/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ fn test_from_value() -> Result<(), Box<dyn Error>> {
for path in glob.walk(dir) {
let path = path?.into_path();
let meta: Value = serde_json::from_reader(File::open(&path)?)?;
if let Err(e) = from_value(&meta) {
if let Err(e) = from_value(meta) {
panic!("{:?} failed: {e}", path.file_name().unwrap());
}
println!("Example {:?} ok", path.file_name().unwrap());
Expand Down

0 comments on commit 9180f9e

Please sign in to comment.