malachite_base/rounding_modes/to_string.rs
1// Copyright © 2025 Mikhail Hogrefe
2//
3// This file is part of Malachite.
4//
5// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU
6// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version
7// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.
8
9use crate::rounding_modes::RoundingMode;
10use core::fmt::{Debug, Display, Formatter, Result};
11
12impl Display for RoundingMode {
13 /// Converts a [`RoundingMode`] to a [`String`].
14 ///
15 /// # Worst-case complexity
16 /// Constant time and additional memory.
17 ///
18 /// # Examples
19 /// ```
20 /// use malachite_base::rounding_modes::RoundingMode::*;
21 ///
22 /// assert_eq!(Down.to_string(), "Down");
23 /// assert_eq!(Up.to_string(), "Up");
24 /// assert_eq!(Floor.to_string(), "Floor");
25 /// assert_eq!(Ceiling.to_string(), "Ceiling");
26 /// assert_eq!(Nearest.to_string(), "Nearest");
27 /// assert_eq!(Exact.to_string(), "Exact");
28 /// ```
29 #[inline]
30 fn fmt(&self, f: &mut Formatter) -> Result {
31 Debug::fmt(self, f)
32 }
33}