Skip to content

Commit 92ddbdf

Browse files
authored
Merge pull request #390 from serde-rs/try
Override the try macro to eliminate From calls
2 parents 5bf9144 + 86cb0b9 commit 92ddbdf

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/lib.rs

+13
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,19 @@ pub use self::ser::{Serializer, to_string, to_string_pretty, to_vec, to_vec_pret
358358
#[doc(inline)]
359359
pub use self::value::{Map, Number, Value, from_value, to_value};
360360

361+
// We only use our own error type; no need for From conversions provided by the
362+
// standard library's try! macro. This reduces lines of LLVM IR by 4%.
363+
macro_rules! try {
364+
($e:expr) => {
365+
match $e {
366+
::std::result::Result::Ok(val) => val,
367+
::std::result::Result::Err(err) => {
368+
return ::std::result::Result::Err(err)
369+
}
370+
}
371+
}
372+
}
373+
361374
#[macro_use]
362375
mod macros;
363376

0 commit comments

Comments
 (0)