Color

Struct Color 

Source
pub struct Color {
    pub r: u8,
    pub g: u8,
    pub b: u8,
}
Expand description

Represents an RGB color with red, green, and blue components.

Each component is a value between 0 and 255, where:

  • 0 represents no intensity
  • 255 represents full intensity

§Examples

use tinterm::Color;

// Create a red color
let red = Color::new(255, 0, 0);

// Use predefined colors
let blue = Color::BLUE;

// Create from hex string
let orange = Color::from_hex("#FF8000").unwrap();

Fields§

§r: u8

Red component (0-255)

§g: u8

Green component (0-255)

§b: u8

Blue component (0-255)

Implementations§

Source§

impl Color

Source

pub fn new(r: u8, g: u8, b: u8) -> Self

Creates a new Color with the specified RGB values.

§Arguments
  • r - Red component (0-255)
  • g - Green component (0-255)
  • b - Blue component (0-255)
§Examples
use tinterm::Color;

let purple = Color::new(128, 0, 128);
Examples found in repository?
examples/art_and_logos.rs (line 211)
190fn display_fire_effect() {
191    println!("\nFire Effect:");
192
193    let flames = vec![
194        "                    ░░░",
195        "                  ░░▒▒░",
196        "                ░▒▒▓▓▒░",
197        "              ░▒▓▓██▓▒░",
198        "            ░▒▓██████▓▒░",
199        "          ░▒▓████████▓▒░",
200        "        ░▒▓▓██████████▓▒░",
201        "      ░▒▓▓████████████▓▓▒░",
202        "    ░▒▓▓██████████████▓▓▒░",
203        "  ░▒▓▓████████████████▓▓▒░░",
204    ];
205
206    for (i, flame) in flames.iter().enumerate() {
207        let intensity = (flames.len() - i) as f32 / flames.len() as f32;
208        let red_component = (255.0 * intensity) as u8;
209        let yellow_component = (255.0 * intensity * 0.8) as u8;
210
211        let fire_color = Color::new(red_component, yellow_component, 0);
212        println!("  {}", flame.color(fire_color));
213    }
214}
More examples
Hide additional examples
examples/comprehensive_demo.rs (line 11)
3fn main() {
4    println!("🎨 Tinterm Comprehensive Demo 🎨\n");
5
6    // Section 1: Basic Colors
7    println!("=== 1. BASIC COLORS ===");
8    println!("{}", "Red Text".color(Color::RED));
9    println!("{}", "Green Background".bg(Color::GREEN));
10    println!("{}", "Blue on Yellow".fg(Color::BLUE).bg(Color::YELLOW));
11    println!("{}", "Custom RGB Color".color(Color::new(255, 165, 0))); // Orange
12    println!("{}", "Hex Color".color(Color::from_hex("#FF69B4").unwrap())); // Hot Pink
13    println!();
14
15    // Section 2: Text Styling
16    println!("=== 2. TEXT STYLING ===");
17    println!("{}", "Bold Text".bold());
18    println!("{}", "Italic Text".italic());
19    println!("{}", "Underlined Text".underline());
20    println!("{}", "Strikethrough Text".strikethrough());
21    println!("{}", "Dim Text".dim());
22    println!("{}", "Bright Text".bright());
23    println!("{}", "Reversed Text".reverse());
24    println!("{}", "Blinking Text".blink());
25    println!();
26
27    // Section 3: Method Chaining
28    println!("=== 3. METHOD CHAINING ===");
29    println!(
30        "{}",
31        "Bold Red on Blue".bold().color(Color::RED).bg(Color::BLUE)
32    );
33    println!(
34        "{}",
35        "Italic Underlined Green"
36            .italic()
37            .underline()
38            .color(Color::GREEN)
39    );
40    println!(
41        "{}",
42        "Bright Magenta with Cyan BG"
43            .bright()
44            .color(Color::MAGENTA)
45            .bg(Color::CYAN)
46    );
47    println!();
48
49    // Section 4: Gradients
50    println!("=== 4. GRADIENTS ===");
51    println!("Foreground Gradients:");
52    println!(
53        "{}",
54        "Red to Blue Gradient".gradient(Color::RED, Color::BLUE, None)
55    );
56    println!(
57        "{}",
58        "Green to Purple Gradient".gradient(Color::GREEN, Color::PURPLE, None)
59    );
60    println!(
61        "{}",
62        "Sunset Colors".gradient(Color::ORANGE, Color::DEEP_PINK, None)
63    );
64
65    println!("\nBackground Gradients:");
66    println!(
67        "{}",
68        "Ocean Waves".gradient_bg(Color::DEEP_SKY_BLUE, Color::TEAL, None)
69    );
70    println!(
71        "{}",
72        "Forest Floor".gradient_bg(Color::DARK_GREEN, Color::BROWN, None)
73    );
74
75    println!("\nMultiline Gradients:");
76    let multiline = "Line One\nLine Two\nLine Three";
77    println!("Block mode (each line separate):");
78    println!(
79        "{}",
80        multiline.gradient(Color::RED, Color::BLUE, Some(true))
81    );
82    println!("Continuous mode (across lines):");
83    println!(
84        "{}",
85        multiline.gradient(Color::CYAN, Color::MAGENTA, Some(false))
86    );
87    println!();
88
89    // Section 5: Shimmer Effects
90    println!("=== 5. SHIMMER EFFECTS ===");
91    println!("Static Shimmer Renders:");
92    println!(
93        "{}",
94        "✨ Golden Shimmer ✨"
95            .shimmer(Color::GOLD, None)
96            .static_render()
97    );
98    println!(
99        "{}",
100        "💎 Diamond Shine 💎".shine(Color::WHITE).static_render()
101    );
102    println!(
103        "{}",
104        "🌟 Stellar Glow 🌟"
105            .glow(Color::YELLOW, 200)
106            .static_render()
107    );
108    println!(
109        "{}",
110        "🌈 Rainbow Gradient 🌈"
111            .shimmer_gradient(Color::RED, Color::VIOLET, None)
112            .static_render()
113    );
114    println!();
115
116    // Section 6: Predefined Colors Showcase
117    println!("=== 6. PREDEFINED COLORS SHOWCASE ===");
118    let colors = vec![
119        ("Fire", Color::RED),
120        ("Ocean", Color::BLUE),
121        ("Forest", Color::GREEN),
122        ("Sun", Color::YELLOW),
123        ("Lavender", Color::LAVENDER),
124        ("Coral", Color::CORAL),
125        ("Gold", Color::GOLD),
126        ("Silver", Color::SILVER),
127        ("Rose", Color::HOT_PINK),
128        ("Emerald", Color::LIME_GREEN),
129    ];
130
131    for (name, color) in colors {
132        println!("{}", format!("● {}", name).color(color));
133    }
134    println!();
135
136    // Section 7: Creative Combinations
137    println!("=== 7. CREATIVE COMBINATIONS ===");
138
139    // Logo-style text
140    println!(
141        "{}",
142        "T".color(Color::RED).to_string()
143            + &"I".color(Color::ORANGE).to_string()
144            + &"N".color(Color::YELLOW).to_string()
145            + &"T".color(Color::GREEN).to_string()
146            + &"E".color(Color::BLUE).to_string()
147            + &"R".color(Color::INDIGO).to_string()
148            + &"M".color(Color::VIOLET)
149    );
150
151    // Progress bar simulation
152    let _progress_full = "████████████████████";
153    let _progress_empty = "░░░░░░░░░░░░░░░░░░░░";
154    println!(
155        "Progress: [{}{}] 75%",
156        "███████████████".bg(Color::GREEN),
157        "░░░░░".color(Color::DARK_GRAY)
158    );
159
160    // Status indicators
161    println!("Status: {} Ready", "●".color(Color::GREEN));
162    println!("Status: {} Warning", "●".color(Color::YELLOW));
163    println!("Status: {} Error", "●".color(Color::RED));
164
165    // Syntax highlighting simulation
166    println!("\nSyntax Highlighting Example:");
167    println!(
168        "{} {} {} {}{}{}",
169        "fn".color(Color::PURPLE),
170        "main".color(Color::BLUE),
171        "()".color(Color::YELLOW),
172        "{".color(Color::WHITE),
173        "\n    println!".color(Color::CYAN),
174        "();".color(Color::WHITE)
175    );
176    println!("{}", "}".color(Color::WHITE));
177    println!();
178
179    // Section 8: Performance Test
180    println!("=== 8. PERFORMANCE TEST ===");
181    let start = std::time::Instant::now();
182    for i in 0..1000 {
183        let _colored = format!("Line {}", i).color(Color::BLUE);
184    }
185    let duration = start.elapsed();
186    println!("Rendered 1000 colored strings in: {:?}", duration);
187
188    // Final showcase
189    println!(
190        "\n{}",
191        "🎉 Tinterm Demo Complete! 🎉".gradient(Color::RED, Color::BLUE, None)
192    );
193    println!(
194        "{}",
195        "Thank you for using Tinterm!"
196            .shimmer(Color::GOLD, None)
197            .static_render()
198    );
199}
Source

pub fn rgb(r: u8, g: u8, b: u8) -> Self

Creates a new Color with the specified RGB values.

This is an alias for Color::new.

§Examples
use tinterm::Color;

let cyan = Color::rgb(0, 255, 255);
Source

pub fn from_hex(hex: &str) -> Result<Self, &'static str>

Creates a new Color from a hexadecimal color string.

Supports both 6-digit (e.g., “#FF0000” or “FF0000”) and 3-digit (e.g., “#F00” or “F00”) formats. The ‘#’ prefix is optional.

§Arguments
  • hex - A hex color string
§Returns
  • Ok(Color) - If the hex string is valid
  • Err(&str) - If the hex string is invalid
§Examples
use tinterm::Color;

let red = Color::from_hex("#FF0000").unwrap();
let green = Color::from_hex("00FF00").unwrap();
let blue = Color::from_hex("#00F").unwrap();
Examples found in repository?
examples/comprehensive_demo.rs (line 12)
3fn main() {
4    println!("🎨 Tinterm Comprehensive Demo 🎨\n");
5
6    // Section 1: Basic Colors
7    println!("=== 1. BASIC COLORS ===");
8    println!("{}", "Red Text".color(Color::RED));
9    println!("{}", "Green Background".bg(Color::GREEN));
10    println!("{}", "Blue on Yellow".fg(Color::BLUE).bg(Color::YELLOW));
11    println!("{}", "Custom RGB Color".color(Color::new(255, 165, 0))); // Orange
12    println!("{}", "Hex Color".color(Color::from_hex("#FF69B4").unwrap())); // Hot Pink
13    println!();
14
15    // Section 2: Text Styling
16    println!("=== 2. TEXT STYLING ===");
17    println!("{}", "Bold Text".bold());
18    println!("{}", "Italic Text".italic());
19    println!("{}", "Underlined Text".underline());
20    println!("{}", "Strikethrough Text".strikethrough());
21    println!("{}", "Dim Text".dim());
22    println!("{}", "Bright Text".bright());
23    println!("{}", "Reversed Text".reverse());
24    println!("{}", "Blinking Text".blink());
25    println!();
26
27    // Section 3: Method Chaining
28    println!("=== 3. METHOD CHAINING ===");
29    println!(
30        "{}",
31        "Bold Red on Blue".bold().color(Color::RED).bg(Color::BLUE)
32    );
33    println!(
34        "{}",
35        "Italic Underlined Green"
36            .italic()
37            .underline()
38            .color(Color::GREEN)
39    );
40    println!(
41        "{}",
42        "Bright Magenta with Cyan BG"
43            .bright()
44            .color(Color::MAGENTA)
45            .bg(Color::CYAN)
46    );
47    println!();
48
49    // Section 4: Gradients
50    println!("=== 4. GRADIENTS ===");
51    println!("Foreground Gradients:");
52    println!(
53        "{}",
54        "Red to Blue Gradient".gradient(Color::RED, Color::BLUE, None)
55    );
56    println!(
57        "{}",
58        "Green to Purple Gradient".gradient(Color::GREEN, Color::PURPLE, None)
59    );
60    println!(
61        "{}",
62        "Sunset Colors".gradient(Color::ORANGE, Color::DEEP_PINK, None)
63    );
64
65    println!("\nBackground Gradients:");
66    println!(
67        "{}",
68        "Ocean Waves".gradient_bg(Color::DEEP_SKY_BLUE, Color::TEAL, None)
69    );
70    println!(
71        "{}",
72        "Forest Floor".gradient_bg(Color::DARK_GREEN, Color::BROWN, None)
73    );
74
75    println!("\nMultiline Gradients:");
76    let multiline = "Line One\nLine Two\nLine Three";
77    println!("Block mode (each line separate):");
78    println!(
79        "{}",
80        multiline.gradient(Color::RED, Color::BLUE, Some(true))
81    );
82    println!("Continuous mode (across lines):");
83    println!(
84        "{}",
85        multiline.gradient(Color::CYAN, Color::MAGENTA, Some(false))
86    );
87    println!();
88
89    // Section 5: Shimmer Effects
90    println!("=== 5. SHIMMER EFFECTS ===");
91    println!("Static Shimmer Renders:");
92    println!(
93        "{}",
94        "✨ Golden Shimmer ✨"
95            .shimmer(Color::GOLD, None)
96            .static_render()
97    );
98    println!(
99        "{}",
100        "💎 Diamond Shine 💎".shine(Color::WHITE).static_render()
101    );
102    println!(
103        "{}",
104        "🌟 Stellar Glow 🌟"
105            .glow(Color::YELLOW, 200)
106            .static_render()
107    );
108    println!(
109        "{}",
110        "🌈 Rainbow Gradient 🌈"
111            .shimmer_gradient(Color::RED, Color::VIOLET, None)
112            .static_render()
113    );
114    println!();
115
116    // Section 6: Predefined Colors Showcase
117    println!("=== 6. PREDEFINED COLORS SHOWCASE ===");
118    let colors = vec![
119        ("Fire", Color::RED),
120        ("Ocean", Color::BLUE),
121        ("Forest", Color::GREEN),
122        ("Sun", Color::YELLOW),
123        ("Lavender", Color::LAVENDER),
124        ("Coral", Color::CORAL),
125        ("Gold", Color::GOLD),
126        ("Silver", Color::SILVER),
127        ("Rose", Color::HOT_PINK),
128        ("Emerald", Color::LIME_GREEN),
129    ];
130
131    for (name, color) in colors {
132        println!("{}", format!("● {}", name).color(color));
133    }
134    println!();
135
136    // Section 7: Creative Combinations
137    println!("=== 7. CREATIVE COMBINATIONS ===");
138
139    // Logo-style text
140    println!(
141        "{}",
142        "T".color(Color::RED).to_string()
143            + &"I".color(Color::ORANGE).to_string()
144            + &"N".color(Color::YELLOW).to_string()
145            + &"T".color(Color::GREEN).to_string()
146            + &"E".color(Color::BLUE).to_string()
147            + &"R".color(Color::INDIGO).to_string()
148            + &"M".color(Color::VIOLET)
149    );
150
151    // Progress bar simulation
152    let _progress_full = "████████████████████";
153    let _progress_empty = "░░░░░░░░░░░░░░░░░░░░";
154    println!(
155        "Progress: [{}{}] 75%",
156        "███████████████".bg(Color::GREEN),
157        "░░░░░".color(Color::DARK_GRAY)
158    );
159
160    // Status indicators
161    println!("Status: {} Ready", "●".color(Color::GREEN));
162    println!("Status: {} Warning", "●".color(Color::YELLOW));
163    println!("Status: {} Error", "●".color(Color::RED));
164
165    // Syntax highlighting simulation
166    println!("\nSyntax Highlighting Example:");
167    println!(
168        "{} {} {} {}{}{}",
169        "fn".color(Color::PURPLE),
170        "main".color(Color::BLUE),
171        "()".color(Color::YELLOW),
172        "{".color(Color::WHITE),
173        "\n    println!".color(Color::CYAN),
174        "();".color(Color::WHITE)
175    );
176    println!("{}", "}".color(Color::WHITE));
177    println!();
178
179    // Section 8: Performance Test
180    println!("=== 8. PERFORMANCE TEST ===");
181    let start = std::time::Instant::now();
182    for i in 0..1000 {
183        let _colored = format!("Line {}", i).color(Color::BLUE);
184    }
185    let duration = start.elapsed();
186    println!("Rendered 1000 colored strings in: {:?}", duration);
187
188    // Final showcase
189    println!(
190        "\n{}",
191        "🎉 Tinterm Demo Complete! 🎉".gradient(Color::RED, Color::BLUE, None)
192    );
193    println!(
194        "{}",
195        "Thank you for using Tinterm!"
196            .shimmer(Color::GOLD, None)
197            .static_render()
198    );
199}
Source

pub fn to_hex(&self) -> String

Converts the color to a hexadecimal string representation.

Returns a 6-digit uppercase hex string with ‘#’ prefix.

§Examples
use tinterm::Color;

let red = Color::new(255, 0, 0);
assert_eq!(red.to_hex(), "#FF0000");
Source§

impl Color

Predefined colors for convenience

Source

pub const RED: Color

Source

pub const GREEN: Color

Source

pub const BLUE: Color

Source

pub const YELLOW: Color

Source

pub const MAGENTA: Color

Source

pub const CYAN: Color

Source

pub const WHITE: Color

Source

pub const BLACK: Color

Source

pub const PINK: Color

Source

pub const LIGHT_PINK: Color

Source

pub const HOT_PINK: Color

Source

pub const DEEP_PINK: Color

Source

pub const PALE_VIOLET_RED: Color

Source

pub const MEDIUM_VIOLET_RED: Color

Source

pub const LIGHT_SALMON: Color

Source

pub const SALMON: Color

Source

pub const DARK_SALMON: Color

Source

pub const LIGHT_CORAL: Color

Source

pub const INDIAN_RED: Color

Source

pub const CRIMSON: Color

Source

pub const FIRE_BRICK: Color

Source

pub const DARK_RED: Color

Source

pub const ORANGE_RED: Color

Source

pub const TOMATO: Color

Source

pub const CORAL: Color

Source

pub const DARK_ORANGE: Color

Source

pub const ORANGE: Color

Source

pub const LIGHT_YELLOW: Color

Source

pub const LEMON_CHIFFON: Color

Source

pub const LIGHT_GOLDENROD_YELLOW: Color

Source

pub const PAPAYA_WHIP: Color

Source

pub const MOCCASIN: Color

Source

pub const PEACH_PUFF: Color

Source

pub const PALE_GOLDENROD: Color

Source

pub const KHAKI: Color

Source

pub const DARK_KHAKI: Color

Source

pub const GOLD: Color

Source

pub const CORNSILK: Color

Source

pub const BLANCHED_ALMOND: Color

Source

pub const BISQUE: Color

Source

pub const NAVAJO_WHITE: Color

Source

pub const WHEAT: Color

Source

pub const BURLYWOOD: Color

Source

pub const TAN: Color

Source

pub const ROSY_BROWN: Color

Source

pub const SANDY_BROWN: Color

Source

pub const GOLDENROD: Color

Source

pub const DARK_GOLDENROD: Color

Source

pub const PERU: Color

Source

pub const CHOCOLATE: Color

Source

pub const SADDLE_BROWN: Color

Source

pub const SIENNA: Color

Source

pub const BROWN: Color

Source

pub const MAROON: Color

Source

pub const GREEN_YELLOW: Color

Source

pub const CHARTREUSE: Color

Source

pub const LAWN_GREEN: Color

Source

pub const LIME: Color

Source

pub const LIME_GREEN: Color

Source

pub const PALE_GREEN: Color

Source

pub const LIGHT_GREEN: Color

Source

pub const MEDIUM_SPRING_GREEN: Color

Source

pub const SPRING_GREEN: Color

Source

pub const MEDIUM_SEA_GREEN: Color

Source

pub const SEA_GREEN: Color

Source

pub const FOREST_GREEN: Color

Source

pub const DARK_GREEN: Color

Source

pub const YELLOW_GREEN: Color

Source

pub const OLIVE_DRAB: Color

Source

pub const OLIVE: Color

Source

pub const DARK_OLIVE_GREEN: Color

Source

pub const MEDIUM_AQUAMARINE: Color

Source

pub const DARK_SEA_GREEN: Color

Source

pub const LIGHT_SEA_GREEN: Color

Source

pub const DARK_CYAN: Color

Source

pub const TEAL: Color

Source

pub const AQUA: Color

Source

pub const LIGHT_CYAN: Color

Source

pub const PALE_TURQUOISE: Color

Source

pub const AQUAMARINE: Color

Source

pub const TURQUOISE: Color

Source

pub const MEDIUM_TURQUOISE: Color

Source

pub const DARK_TURQUOISE: Color

Source

pub const CADET_BLUE: Color

Source

pub const STEEL_BLUE: Color

Source

pub const LIGHT_STEEL_BLUE: Color

Source

pub const POWDER_BLUE: Color

Source

pub const LIGHT_BLUE: Color

Source

pub const SKY_BLUE: Color

Source

pub const LIGHT_SKY_BLUE: Color

Source

pub const DEEP_SKY_BLUE: Color

Source

pub const DODGER_BLUE: Color

Source

pub const CORNFLOWER_BLUE: Color

Source

pub const MEDIUM_SLATE_BLUE: Color

Source

pub const ROYAL_BLUE: Color

Source

pub const MEDIUM_BLUE: Color

Source

pub const DARK_BLUE: Color

Source

pub const NAVY: Color

Source

pub const MIDNIGHT_BLUE: Color

Source

pub const LAVENDER: Color

Source

pub const THISTLE: Color

Source

pub const PLUM: Color

Source

pub const VIOLET: Color

Source

pub const ORCHID: Color

Source

pub const FUCHSIA: Color

Source

pub const MEDIUM_ORCHID: Color

Source

pub const MEDIUM_PURPLE: Color

Source

pub const BLUE_VIOLET: Color

Source

pub const DARK_VIOLET: Color

Source

pub const DARK_ORCHID: Color

Source

pub const DARK_MAGENTA: Color

Source

pub const PURPLE: Color

Source

pub const INDIGO: Color

Source

pub const SLATE_BLUE: Color

Source

pub const DARK_SLATE_BLUE: Color

Source

pub const GAINSBORO: Color

Source

pub const LIGHT_GRAY: Color

Source

pub const SILVER: Color

Source

pub const DARK_GRAY: Color

Source

pub const GRAY: Color

Source

pub const DIM_GRAY: Color

Source

pub const LIGHT_SLATE_GRAY: Color

Source

pub const SLATE_GRAY: Color

Source

pub const DARK_SLATE_GRAY: Color

Source

pub const ALICE_BLUE: Color

Source

pub const GHOST_WHITE: Color

Source

pub const HONEYDEW: Color

Source

pub const IVORY: Color

Source

pub const AZURE: Color

Source

pub const SNOW: Color

Source

pub const FLORAL_WHITE: Color

Source

pub const WHITE_SMOKE: Color

Source

pub const SEASHELL: Color

Source

pub const BEIGE: Color

Source

pub const OLD_LACE: Color

Source

pub const MINT_CREAM: Color

Source

pub const LAVENDER_BLUSH: Color

Source

pub const MISTY_ROSE: Color

Trait Implementations§

Source§

impl Clone for Color

Source§

fn clone(&self) -> Color

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Color

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Color

Source§

fn eq(&self, other: &Color) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Color

Source§

impl Eq for Color

Source§

impl StructuralPartialEq for Color

Auto Trait Implementations§

§

impl Freeze for Color

§

impl RefUnwindSafe for Color

§

impl Send for Color

§

impl Sync for Color

§

impl Unpin for Color

§

impl UnwindSafe for Color

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.