Skip to content

Commit 680389f

Browse files
committed
Accept impl ToString as msg in get_rpc_status and get_status
So that we do not need the .to_string() in every call of get_status or get_rpc_status. e.g.: get_rpc_status(ttrpc::Code::INTERNAL, e.to_string()) -> get_rpc_status(ttrpc::Code::INTERNAL, e)) Signed-off-by: Tim Zhang <[email protected]>
1 parent 8f99147 commit 680389f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/error.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ pub enum Error {
3535
pub type Result<T> = result::Result<T, Error>;
3636

3737
/// Get ttrpc::Status from ttrpc::Code and a message.
38-
pub fn get_status(c: Code, msg: String) -> Status {
38+
pub fn get_status(c: Code, msg: impl ToString) -> Status {
3939
let mut status = Status::new();
4040
status.set_code(c);
41-
status.set_message(msg);
41+
status.set_message(msg.to_string());
4242

4343
status
4444
}
4545

46-
pub fn get_rpc_status(c: Code, msg: String) -> Error {
46+
pub fn get_rpc_status(c: Code, msg: impl ToString) -> Error {
4747
Error::RpcStatus(get_status(c, msg))
4848
}
4949

0 commit comments

Comments
 (0)