Skip to content

Commit b84c862

Browse files
authored
Merge pull request #398 from ramon-garcia/master
Idiomatic change in saved_model.rs
2 parents ae92c63 + ac2a13f commit b84c862

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/saved_model.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -495,16 +495,12 @@ impl SavedModelSaver {
495495
) -> std::result::Result<(), SaveModelError> {
496496
let mut meta_graph = self.meta_graph.clone();
497497
let graph_bytes = graph.graph_def()?;
498-
let graph_def = match protobuf::Message::parse_from_bytes(&graph_bytes) {
499-
Ok(x) => x,
500-
Err(e) => {
501-
return Err(Status::new_set_lossy(
502-
Code::InvalidArgument,
503-
&format!("Unable to parse graph definition: {}", e),
504-
)
505-
.into());
506-
}
507-
};
498+
let graph_def = protobuf::Message::parse_from_bytes(&graph_bytes).map_err(|e| {
499+
SaveModelError::from(Status::new_set_lossy(
500+
Code::InvalidArgument,
501+
&format!("Unable to parse graph definition: {}", e),
502+
))
503+
})?;
508504
meta_graph.set_graph_def(graph_def);
509505
let mut saved_model = protos::saved_model::SavedModel::new();
510506
saved_model.set_saved_model_schema_version(1);

0 commit comments

Comments
 (0)