From 385b3b230fe598dfae71f2b6d66a3502f5329dbc Mon Sep 17 00:00:00 2001 From: David Pedersen Date: Sat, 13 Feb 2021 19:27:31 +0100 Subject: [PATCH] Implement `From` for `i32` `Code` is already trivial to convert into an `i32` however that isn't immediately obvious by looking at the docs. This has tripped me up before. Implementing `From` for `i32` should hopefully make it a bit more obvious. --- tonic/src/status.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tonic/src/status.rs b/tonic/src/status.rs index 34070e2b9..17336c438 100644 --- a/tonic/src/status.rs +++ b/tonic/src/status.rs @@ -746,6 +746,13 @@ impl From for Code { } } +impl From for i32 { + #[inline] + fn from(code: Code) -> i32 { + code as i32 + } +} + #[cfg(test)] mod tests { use super::*;