summaryrefslogtreecommitdiffstats
path: root/vendor/anstyle/src
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
commitc23a457e72abe608715ac76f076f47dc42af07a5 (patch)
tree2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /vendor/anstyle/src
parentReleasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz
rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/anstyle/src')
-rw-r--r--vendor/anstyle/src/color.rs35
-rw-r--r--vendor/anstyle/src/effect.rs3
-rw-r--r--vendor/anstyle/src/reset.rs3
-rw-r--r--vendor/anstyle/src/style.rs5
4 files changed, 25 insertions, 21 deletions
diff --git a/vendor/anstyle/src/color.rs b/vendor/anstyle/src/color.rs
index cbf0b47a2..8dcf6ca5b 100644
--- a/vendor/anstyle/src/color.rs
+++ b/vendor/anstyle/src/color.rs
@@ -17,13 +17,13 @@ impl Color {
/// Create a [`Style`][crate::Style] with this as the foreground
#[inline]
- pub fn on_default(self) -> crate::Style {
+ pub const fn on_default(self) -> crate::Style {
crate::Style::new().fg_color(Some(self))
}
/// Render the ANSI code for a foreground color
#[inline]
- pub fn render_fg(self) -> impl core::fmt::Display {
+ pub fn render_fg(self) -> impl core::fmt::Display + Copy + Clone {
match self {
Self::Ansi(color) => DisplayBuffer::default().write_str(color.as_fg_str()),
Self::Ansi256(color) => color.as_fg_buffer(),
@@ -44,7 +44,7 @@ impl Color {
/// Render the ANSI code for a background color
#[inline]
- pub fn render_bg(self) -> impl core::fmt::Display {
+ pub fn render_bg(self) -> impl core::fmt::Display + Copy + Clone {
match self {
Self::Ansi(color) => DisplayBuffer::default().write_str(color.as_bg_str()),
Self::Ansi256(color) => color.as_bg_buffer(),
@@ -64,7 +64,7 @@ impl Color {
}
#[inline]
- pub(crate) fn render_underline(self) -> impl core::fmt::Display {
+ pub(crate) fn render_underline(self) -> impl core::fmt::Display + Copy + Clone {
match self {
Self::Ansi(color) => color.as_underline_buffer(),
Self::Ansi256(color) => color.as_underline_buffer(),
@@ -185,13 +185,13 @@ impl AnsiColor {
/// Create a [`Style`][crate::Style] with this as the foreground
#[inline]
- pub fn on_default(self) -> crate::Style {
- crate::Style::new().fg_color(Some(self.into()))
+ pub const fn on_default(self) -> crate::Style {
+ crate::Style::new().fg_color(Some(Color::Ansi(self)))
}
/// Render the ANSI code for a foreground color
#[inline]
- pub fn render_fg(self) -> impl core::fmt::Display {
+ pub fn render_fg(self) -> impl core::fmt::Display + Copy + Clone {
self.as_fg_str()
}
@@ -219,7 +219,7 @@ impl AnsiColor {
/// Render the ANSI code for a background color
#[inline]
- pub fn render_bg(self) -> impl core::fmt::Display {
+ pub fn render_bg(self) -> impl core::fmt::Display + Copy + Clone {
self.as_bg_str()
}
@@ -340,8 +340,8 @@ impl Ansi256Color {
/// Create a [`Style`][crate::Style] with this as the foreground
#[inline]
- pub fn on_default(self) -> crate::Style {
- crate::Style::new().fg_color(Some(self.into()))
+ pub const fn on_default(self) -> crate::Style {
+ crate::Style::new().fg_color(Some(Color::Ansi256(self)))
}
#[inline]
@@ -396,7 +396,7 @@ impl Ansi256Color {
/// Render the ANSI code for a foreground color
#[inline]
- pub fn render_fg(self) -> impl core::fmt::Display {
+ pub fn render_fg(self) -> impl core::fmt::Display + Copy + Clone {
self.as_fg_buffer()
}
@@ -410,7 +410,7 @@ impl Ansi256Color {
/// Render the ANSI code for a background color
#[inline]
- pub fn render_bg(self) -> impl core::fmt::Display {
+ pub fn render_bg(self) -> impl core::fmt::Display + Copy + Clone {
self.as_bg_buffer()
}
@@ -460,8 +460,8 @@ impl RgbColor {
/// Create a [`Style`][crate::Style] with this as the foreground
#[inline]
- pub fn on_default(self) -> crate::Style {
- crate::Style::new().fg_color(Some(self.into()))
+ pub const fn on_default(self) -> crate::Style {
+ crate::Style::new().fg_color(Some(Color::Rgb(self)))
}
#[inline]
@@ -481,7 +481,7 @@ impl RgbColor {
/// Render the ANSI code for a foreground color
#[inline]
- pub fn render_fg(self) -> impl core::fmt::Display {
+ pub fn render_fg(self) -> impl core::fmt::Display + Copy + Clone {
self.as_fg_buffer()
}
@@ -499,7 +499,7 @@ impl RgbColor {
/// Render the ANSI code for a background color
#[inline]
- pub fn render_bg(self) -> impl core::fmt::Display {
+ pub fn render_bg(self) -> impl core::fmt::Display + Copy + Clone {
self.as_bg_buffer()
}
@@ -536,7 +536,7 @@ impl From<(u8, u8, u8)> for RgbColor {
}
}
-#[derive(Default, Debug)]
+#[derive(Copy, Clone, Default, Debug)]
struct DisplayBuffer {
buffer: [u8; 19],
len: usize,
@@ -598,6 +598,7 @@ impl core::fmt::Display for DisplayBuffer {
}
#[cfg(test)]
+#[cfg(feature = "std")]
mod test {
use super::*;
diff --git a/vendor/anstyle/src/effect.rs b/vendor/anstyle/src/effect.rs
index d31dafe82..56b3e615c 100644
--- a/vendor/anstyle/src/effect.rs
+++ b/vendor/anstyle/src/effect.rs
@@ -156,7 +156,7 @@ impl Effects {
/// Render the ANSI code
#[inline]
- pub fn render(self) -> impl core::fmt::Display {
+ pub fn render(self) -> impl core::fmt::Display + Copy + Clone {
EffectsDisplay(self)
}
@@ -307,6 +307,7 @@ pub(crate) const METADATA: [Metadata; 12] = [
},
];
+#[derive(Copy, Clone, Default, Debug)]
struct EffectsDisplay(Effects);
impl core::fmt::Display for EffectsDisplay {
diff --git a/vendor/anstyle/src/reset.rs b/vendor/anstyle/src/reset.rs
index 5f5f2b461..c8c214093 100644
--- a/vendor/anstyle/src/reset.rs
+++ b/vendor/anstyle/src/reset.rs
@@ -5,11 +5,12 @@ pub struct Reset;
impl Reset {
/// Render the ANSI code
#[inline]
- pub fn render(self) -> impl core::fmt::Display {
+ pub fn render(self) -> impl core::fmt::Display + Copy + Clone {
ResetDisplay
}
}
+#[derive(Copy, Clone, Default, Debug)]
struct ResetDisplay;
impl core::fmt::Display for ResetDisplay {
diff --git a/vendor/anstyle/src/style.rs b/vendor/anstyle/src/style.rs
index e0cad29d2..f4da242b3 100644
--- a/vendor/anstyle/src/style.rs
+++ b/vendor/anstyle/src/style.rs
@@ -92,7 +92,7 @@ impl Style {
/// Render the ANSI code
#[inline]
- pub fn render(self) -> impl core::fmt::Display {
+ pub fn render(self) -> impl core::fmt::Display + Copy + Clone {
StyleDisplay(self)
}
@@ -121,7 +121,7 @@ impl Style {
///
/// Unlike [`Reset::render`][crate::Reset::render], this will elide the code if there is nothing to reset.
#[inline]
- pub fn render_reset(self) -> impl core::fmt::Display {
+ pub fn render_reset(self) -> impl core::fmt::Display + Copy + Clone {
if self != Self::new() {
RESET
} else {
@@ -374,6 +374,7 @@ impl core::cmp::PartialEq<crate::Effects> for Style {
}
}
+#[derive(Copy, Clone, Default, Debug)]
struct StyleDisplay(Style);
impl core::fmt::Display for StyleDisplay {