[fractal] Implement Display instead of ToString trait
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal] Implement Display instead of ToString trait
- Date: Wed, 27 Apr 2022 14:01:31 +0000 (UTC)
commit 341c1258187478acac94528b72dbd3616d539e7e
Author: Julian Sparber <julian sparber net>
Date: Wed Apr 27 14:38:22 2022 +0200
Implement Display instead of ToString trait
Part-of: <https://gitlab.gnome.org/GNOME/fractal/-/merge_requests/1086>
src/session/room/room_type.rs | 8 ++++----
src/session/sidebar/category_type.rs | 11 +++++++----
src/session/sidebar/entry_type.rs | 12 ++++++++----
3 files changed, 19 insertions(+), 12 deletions(-)
---
diff --git a/src/session/room/room_type.rs b/src/session/room/room_type.rs
index 1dc3ab9b3..1cbe46776 100644
--- a/src/session/room/room_type.rs
+++ b/src/session/room/room_type.rs
@@ -1,4 +1,4 @@
-use std::convert::TryFrom;
+use std::{convert::TryFrom, fmt};
use gtk::glib;
use num_enum::{IntoPrimitive, TryFromPrimitive};
@@ -73,9 +73,9 @@ impl Default for RoomType {
}
}
-impl ToString for RoomType {
- fn to_string(&self) -> String {
- CategoryType::from(self).to_string()
+impl fmt::Display for RoomType {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ CategoryType::from(self).fmt(f)
}
}
diff --git a/src/session/sidebar/category_type.rs b/src/session/sidebar/category_type.rs
index c31ce3ff9..ae1a72dcd 100644
--- a/src/session/sidebar/category_type.rs
+++ b/src/session/sidebar/category_type.rs
@@ -1,3 +1,5 @@
+use std::fmt;
+
use gettextrs::gettext;
use gtk::glib;
@@ -25,9 +27,9 @@ impl Default for CategoryType {
}
}
-impl ToString for CategoryType {
- fn to_string(&self) -> String {
- match self {
+impl fmt::Display for CategoryType {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ let label = match self {
CategoryType::None => unimplemented!(),
CategoryType::VerificationRequest => gettext("Verifications"),
CategoryType::Invited => gettext("Invited"),
@@ -39,7 +41,8 @@ impl ToString for CategoryType {
CategoryType::Outdated => gettext("Outdated"),
CategoryType::Space => gettext("Spaces"),
CategoryType::Direct => gettext("People"),
- }
+ };
+ f.write_str(&label)
}
}
diff --git a/src/session/sidebar/entry_type.rs b/src/session/sidebar/entry_type.rs
index 366739375..fa67bb04d 100644
--- a/src/session/sidebar/entry_type.rs
+++ b/src/session/sidebar/entry_type.rs
@@ -1,3 +1,5 @@
+use std::fmt;
+
use gettextrs::gettext;
use gtk::glib;
@@ -15,11 +17,13 @@ impl Default for EntryType {
}
}
-impl ToString for EntryType {
- fn to_string(&self) -> String {
- match self {
+impl fmt::Display for EntryType {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ let label = match self {
EntryType::Explore => gettext("Explore"),
EntryType::Forget => gettext("Forget Room"),
- }
+ };
+
+ f.write_str(&label)
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]