From cd852cebb7bbfe971693f3e483d24e3771f7d120 Mon Sep 17 00:00:00 2001 From: nathan Date: Sun, 8 Dec 2024 17:39:56 +0800 Subject: [PATCH] chore: clippy --- .../src/services/cell/type_cell_data.rs | 14 +++++--------- .../src/services/field/type_options/util.rs | 7 ++++--- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/frontend/rust-lib/flowy-database2/src/services/cell/type_cell_data.rs b/frontend/rust-lib/flowy-database2/src/services/cell/type_cell_data.rs index ccc877059a80a..09bd13793a25f 100644 --- a/frontend/rust-lib/flowy-database2/src/services/cell/type_cell_data.rs +++ b/frontend/rust-lib/flowy-database2/src/services/cell/type_cell_data.rs @@ -1,4 +1,5 @@ use bytes::Bytes; +use std::fmt::Display; use flowy_error::{internal_error, FlowyResult}; @@ -64,15 +65,10 @@ impl CellProtobufBlob { // } } -impl ToString for CellProtobufBlob { - fn to_string(&self) -> String { - match String::from_utf8(self.0.to_vec()) { - Ok(s) => s, - Err(e) => { - tracing::error!("DecodedCellData to string failed: {:?}", e); - "".to_string() - }, - } +impl Display for CellProtobufBlob { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let s = String::from_utf8(self.0.to_vec()).unwrap_or_default(); + write!(f, "{}", s) } } diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/util.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/util.rs index 6bf03b127aabb..ec06f84e61f65 100644 --- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/util.rs +++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/util.rs @@ -1,5 +1,6 @@ use bytes::Bytes; use protobuf::ProtobufError; +use std::fmt::Display; #[derive(Default, Debug, Clone)] pub struct ProtobufStr(pub String); @@ -23,9 +24,9 @@ impl std::convert::From for ProtobufStr { } } -impl ToString for ProtobufStr { - fn to_string(&self) -> String { - self.0.clone() +impl Display for ProtobufStr { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.0.clone()) } }