Skip to content

Commit

Permalink
Merge pull request #185 from sabify/dir-display
Browse files Browse the repository at this point in the history
feat: implement `Display` for direction
  • Loading branch information
Baptistemontan authored Feb 6, 2025
2 parents d33ce92 + 26d1c99 commit ccac31f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions leptos_i18n/src/locale_traits.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use icu_locid::{LanguageIdentifier, Locale as IcuLocale};
use std::str::FromStr;
use std::{fmt::Debug, hash::Hash};
use std::{
fmt::{Debug, Display},
hash::Hash,
str::FromStr,
};

use crate::langid::{convert_vec_str_to_langids_lossy, filter_matches, find_match};

Expand Down Expand Up @@ -143,6 +146,12 @@ pub enum Direction {
Auto,
}

impl Display for Direction {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.as_str())
}
}

impl Direction {
/// Return the string representation for the the html `dir` attribute: "ltr", "rtl" and "auto".
pub const fn as_str(self) -> &'static str {
Expand Down

0 comments on commit ccac31f

Please sign in to comment.