Skip to content

Commit

Permalink
feat(tonic): implement From<Code> for i32
Browse files Browse the repository at this point in the history
`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<Code>` for `i32` should hopefully make it a bit more
obvious.
  • Loading branch information
davidpdrsn authored May 12, 2021
1 parent c39404d commit f33316d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tonic/src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,13 @@ impl From<i32> for Code {
}
}

impl From<Code> for i32 {
#[inline]
fn from(code: Code) -> i32 {
code as i32
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down

0 comments on commit f33316d

Please sign in to comment.