Theme

Struct Theme 

Source
pub struct Theme { /* private fields */ }
Expand description

The theme of the file explorer.

This struct is used to customize the look of the file explorer. It allows to set the style of the widget and the style of the files. You can also wrap the widget in a block with the Theme::with_block method and add customizable titles to it with Theme::with_title_top and Theme::with_title_bottom.

Implementations§

Source§

impl Theme

Source

pub const fn new() -> Self

Create a new empty theme.

The theme will not have any style set. To get a theme with the default style, use Theme::default.

§Example
let theme = Theme::new();
Examples found in repository?
examples/light_and_dark_theme.rs (line 63)
62fn get_light_theme() -> Theme {
63    Theme::new()
64        .with_block(
65            Block::default()
66                .borders(Borders::ALL)
67                .border_type(BorderType::Rounded)
68                .style(Style::default().fg(Color::Black).bg(Color::White)),
69        )
70        .with_item_style(Style::default().fg(Color::Yellow))
71        .with_dir_style(
72            Style::default()
73                .fg(Color::Cyan)
74                .add_modifier(Modifier::BOLD),
75        )
76        .with_highlight_symbol("> ")
77        .add_default_title()
78        .with_title_top(|_| Line::from(" ☀ Theme ").right_aligned())
79        .with_title_bottom(|_| " ^q Quit | ^s Switch theme ".into())
80}
81
82fn get_dark_theme() -> Theme {
83    Theme::new()
84        .with_block(
85            Block::default()
86                .borders(Borders::ALL)
87                .border_type(BorderType::Rounded)
88                .style(Style::default().fg(Color::White).bg(Color::Black)),
89        )
90        .with_item_style(Style::default().fg(Color::Yellow))
91        .with_dir_style(
92            Style::default()
93                .fg(Color::Cyan)
94                .add_modifier(Modifier::BOLD),
95        )
96        .with_highlight_symbol("> ")
97        .add_default_title()
98        .with_title_top(|_| Line::from(" ☾ Theme ").right_aligned())
99        .with_title_bottom(|_| " ^q Quit | ^s Switch theme ".into())
100}
Source

pub fn add_default_title(self) -> Self

Add a top title to the theme. The title is the current working directory.

§Example

Suppose you have this tree file, with passport.png selected inside file_explorer:

/
├── .git
└── Documents
    ├── passport.png  <- selected
    └── resume.pdf

You will end up with something like this:

┌/Documents────────────────────────┐
│ ../                              │
│ passport.png                     │
│ resume.pdf                       │
└──────────────────────────────────┘

With this code:

use ratatui::widgets::*;
use fpicker::{FileExplorer, Theme};

let theme = Theme::default()
    .with_block(Block::default().borders(Borders::ALL))
    .add_default_title();

let file_explorer = FileExplorer::with_theme(theme).unwrap();

/* user select `password.png` */

let widget = file_explorer.widget();
/* render the widget */
Examples found in repository?
examples/light_and_dark_theme.rs (line 77)
62fn get_light_theme() -> Theme {
63    Theme::new()
64        .with_block(
65            Block::default()
66                .borders(Borders::ALL)
67                .border_type(BorderType::Rounded)
68                .style(Style::default().fg(Color::Black).bg(Color::White)),
69        )
70        .with_item_style(Style::default().fg(Color::Yellow))
71        .with_dir_style(
72            Style::default()
73                .fg(Color::Cyan)
74                .add_modifier(Modifier::BOLD),
75        )
76        .with_highlight_symbol("> ")
77        .add_default_title()
78        .with_title_top(|_| Line::from(" ☀ Theme ").right_aligned())
79        .with_title_bottom(|_| " ^q Quit | ^s Switch theme ".into())
80}
81
82fn get_dark_theme() -> Theme {
83    Theme::new()
84        .with_block(
85            Block::default()
86                .borders(Borders::ALL)
87                .border_type(BorderType::Rounded)
88                .style(Style::default().fg(Color::White).bg(Color::Black)),
89        )
90        .with_item_style(Style::default().fg(Color::Yellow))
91        .with_dir_style(
92            Style::default()
93                .fg(Color::Cyan)
94                .add_modifier(Modifier::BOLD),
95        )
96        .with_highlight_symbol("> ")
97        .add_default_title()
98        .with_title_top(|_| Line::from(" ☾ Theme ").right_aligned())
99        .with_title_bottom(|_| " ^q Quit | ^s Switch theme ".into())
100}
More examples
Hide additional examples
examples/basic.rs (line 18)
11fn main() -> io::Result<()> {
12    enable_raw_mode()?;
13    stdout().execute(EnterAlternateScreen)?;
14
15    let mut terminal = Terminal::new(CrosstermBackend::new(stdout()))?;
16
17    // Create a new file explorer with the default theme and title.
18    let theme = Theme::default().add_default_title();
19    let mut file_explorer = FileExplorer::with_theme(theme)?;
20
21    let mut selected_paths = vec![];
22
23    loop {
24        // Render the file explorer widget.
25        terminal.draw(|f| {
26            f.render_widget(&file_explorer.widget(), f.area());
27        })?;
28
29        // Read the next event from the terminal.
30        let event = read()?;
31        if let Event::Key(key) = event {
32            if key.code == KeyCode::Char('q') {
33                // Collect selected file paths.
34                selected_paths = file_explorer
35                    .selected_files()
36                    .iter()
37                    .map(|file| file.path().display().to_string())
38                    .collect();
39                break;
40            }
41        }
42        // Handle the event in the file explorer.
43        file_explorer.handle(&event)?;
44    }
45
46    // Restore the terminal to normal mode.
47    disable_raw_mode()?;
48    stdout().execute(LeaveAlternateScreen)?;
49
50    // Print the selected file paths to stdout.
51    for path in selected_paths {
52        println!("{}", path);
53    }
54
55    // Return exit code 0 explicitly.
56    process::exit(0);
57}
Source

pub fn with_block(self, block: Block<'static>) -> Self

Wrap the file explorer with a custom Block widget.

Behind the scene, it use the List::block method. See its documentation for more.

You can use Theme::with_title_top and Theme::with_title_bottom to add customizable titles to the block.

§Example
let theme = Theme::default().with_block(Block::default().borders(Borders::ALL));
Examples found in repository?
examples/file_preview.rs (line 139)
137fn get_theme() -> Theme {
138    Theme::default()
139        .with_block(Block::default().borders(Borders::ALL))
140        .with_dir_style(
141            Style::default()
142                .fg(Color::White)
143                .add_modifier(Modifier::BOLD),
144        )
145        .with_highlight_dir_style(
146            Style::default()
147                .fg(Color::White)
148                .add_modifier(Modifier::BOLD)
149                .bg(Color::DarkGray),
150        )
151}
More examples
Hide additional examples
examples/light_and_dark_theme.rs (lines 64-69)
62fn get_light_theme() -> Theme {
63    Theme::new()
64        .with_block(
65            Block::default()
66                .borders(Borders::ALL)
67                .border_type(BorderType::Rounded)
68                .style(Style::default().fg(Color::Black).bg(Color::White)),
69        )
70        .with_item_style(Style::default().fg(Color::Yellow))
71        .with_dir_style(
72            Style::default()
73                .fg(Color::Cyan)
74                .add_modifier(Modifier::BOLD),
75        )
76        .with_highlight_symbol("> ")
77        .add_default_title()
78        .with_title_top(|_| Line::from(" ☀ Theme ").right_aligned())
79        .with_title_bottom(|_| " ^q Quit | ^s Switch theme ".into())
80}
81
82fn get_dark_theme() -> Theme {
83    Theme::new()
84        .with_block(
85            Block::default()
86                .borders(Borders::ALL)
87                .border_type(BorderType::Rounded)
88                .style(Style::default().fg(Color::White).bg(Color::Black)),
89        )
90        .with_item_style(Style::default().fg(Color::Yellow))
91        .with_dir_style(
92            Style::default()
93                .fg(Color::Cyan)
94                .add_modifier(Modifier::BOLD),
95        )
96        .with_highlight_symbol("> ")
97        .add_default_title()
98        .with_title_top(|_| Line::from(" ☾ Theme ").right_aligned())
99        .with_title_bottom(|_| " ^q Quit | ^s Switch theme ".into())
100}
Source

pub fn with_style<S: Into<Style>>(self, style: S) -> Self

Set the style of the widget.

Behind the scene, it use the List::style method. See its documentation for more.

§Example
let theme = Theme::default().with_style(Style::default().fg(Color::Yellow));
Source

pub fn with_item_style<S: Into<Style>>(self, item_style: S) -> Self

Set the style of all non directories items. To set the style of the directories, use Theme::with_dir_style.

Behind the scene, it use the Span::styled method. See its documentation for more.

§Example
let theme = Theme::default().with_item_style(Style::default().fg(Color::White));
Examples found in repository?
examples/light_and_dark_theme.rs (line 70)
62fn get_light_theme() -> Theme {
63    Theme::new()
64        .with_block(
65            Block::default()
66                .borders(Borders::ALL)
67                .border_type(BorderType::Rounded)
68                .style(Style::default().fg(Color::Black).bg(Color::White)),
69        )
70        .with_item_style(Style::default().fg(Color::Yellow))
71        .with_dir_style(
72            Style::default()
73                .fg(Color::Cyan)
74                .add_modifier(Modifier::BOLD),
75        )
76        .with_highlight_symbol("> ")
77        .add_default_title()
78        .with_title_top(|_| Line::from(" ☀ Theme ").right_aligned())
79        .with_title_bottom(|_| " ^q Quit | ^s Switch theme ".into())
80}
81
82fn get_dark_theme() -> Theme {
83    Theme::new()
84        .with_block(
85            Block::default()
86                .borders(Borders::ALL)
87                .border_type(BorderType::Rounded)
88                .style(Style::default().fg(Color::White).bg(Color::Black)),
89        )
90        .with_item_style(Style::default().fg(Color::Yellow))
91        .with_dir_style(
92            Style::default()
93                .fg(Color::Cyan)
94                .add_modifier(Modifier::BOLD),
95        )
96        .with_highlight_symbol("> ")
97        .add_default_title()
98        .with_title_top(|_| Line::from(" ☾ Theme ").right_aligned())
99        .with_title_bottom(|_| " ^q Quit | ^s Switch theme ".into())
100}
Source

pub fn with_dir_style<S: Into<Style>>(self, dir_style: S) -> Self

Set the style of all directories items. To set the style of the non directories, use Theme::with_item_style.

Behind the scene, it use the Span::styled method. See its documentation for more.

§Example
let theme = Theme::default().with_dir_style(Style::default().fg(Color::Blue));
Examples found in repository?
examples/file_preview.rs (lines 140-144)
137fn get_theme() -> Theme {
138    Theme::default()
139        .with_block(Block::default().borders(Borders::ALL))
140        .with_dir_style(
141            Style::default()
142                .fg(Color::White)
143                .add_modifier(Modifier::BOLD),
144        )
145        .with_highlight_dir_style(
146            Style::default()
147                .fg(Color::White)
148                .add_modifier(Modifier::BOLD)
149                .bg(Color::DarkGray),
150        )
151}
More examples
Hide additional examples
examples/light_and_dark_theme.rs (lines 71-75)
62fn get_light_theme() -> Theme {
63    Theme::new()
64        .with_block(
65            Block::default()
66                .borders(Borders::ALL)
67                .border_type(BorderType::Rounded)
68                .style(Style::default().fg(Color::Black).bg(Color::White)),
69        )
70        .with_item_style(Style::default().fg(Color::Yellow))
71        .with_dir_style(
72            Style::default()
73                .fg(Color::Cyan)
74                .add_modifier(Modifier::BOLD),
75        )
76        .with_highlight_symbol("> ")
77        .add_default_title()
78        .with_title_top(|_| Line::from(" ☀ Theme ").right_aligned())
79        .with_title_bottom(|_| " ^q Quit | ^s Switch theme ".into())
80}
81
82fn get_dark_theme() -> Theme {
83    Theme::new()
84        .with_block(
85            Block::default()
86                .borders(Borders::ALL)
87                .border_type(BorderType::Rounded)
88                .style(Style::default().fg(Color::White).bg(Color::Black)),
89        )
90        .with_item_style(Style::default().fg(Color::Yellow))
91        .with_dir_style(
92            Style::default()
93                .fg(Color::Cyan)
94                .add_modifier(Modifier::BOLD),
95        )
96        .with_highlight_symbol("> ")
97        .add_default_title()
98        .with_title_top(|_| Line::from(" ☾ Theme ").right_aligned())
99        .with_title_bottom(|_| " ^q Quit | ^s Switch theme ".into())
100}
Source

pub fn with_highlight_item_style<S: Into<Style>>( self, highlight_item_style: S, ) -> Self

Set the style of all highlighted non directories items. To set the style of the highlighted directories, use Theme::with_highlight_dir_style.

Behind the scene, it use the List::highlight_style method. See its documentation for more.

§Example
let theme = Theme::default().with_highlight_item_style(Style::default().add_modifier(Modifier::BOLD));
Source

pub fn with_highlight_dir_style<S: Into<Style>>( self, highlight_dir_style: S, ) -> Self

Set the style of all highlighted directories items. To set the style of the highlighted non directories, use Theme::with_highlight_item_style.

Behind the scene, it use the List::highlight_style method. See its documentation for more.

§Example
let theme = Theme::default().with_highlight_dir_style(Style::default().fg(Color::Blue).add_modifier(Modifier::BOLD));
Examples found in repository?
examples/file_preview.rs (lines 145-150)
137fn get_theme() -> Theme {
138    Theme::default()
139        .with_block(Block::default().borders(Borders::ALL))
140        .with_dir_style(
141            Style::default()
142                .fg(Color::White)
143                .add_modifier(Modifier::BOLD),
144        )
145        .with_highlight_dir_style(
146            Style::default()
147                .fg(Color::White)
148                .add_modifier(Modifier::BOLD)
149                .bg(Color::DarkGray),
150        )
151}
Source

pub fn with_highlight_symbol(self, highlight_symbol: &str) -> Self

Set the symbol used to highlight the selected item.

Behind the scene, it use the List::highlight_symbol method. See its documentation for more.

§Example
let theme = Theme::default().with_highlight_symbol("> ");
Examples found in repository?
examples/light_and_dark_theme.rs (line 76)
62fn get_light_theme() -> Theme {
63    Theme::new()
64        .with_block(
65            Block::default()
66                .borders(Borders::ALL)
67                .border_type(BorderType::Rounded)
68                .style(Style::default().fg(Color::Black).bg(Color::White)),
69        )
70        .with_item_style(Style::default().fg(Color::Yellow))
71        .with_dir_style(
72            Style::default()
73                .fg(Color::Cyan)
74                .add_modifier(Modifier::BOLD),
75        )
76        .with_highlight_symbol("> ")
77        .add_default_title()
78        .with_title_top(|_| Line::from(" ☀ Theme ").right_aligned())
79        .with_title_bottom(|_| " ^q Quit | ^s Switch theme ".into())
80}
81
82fn get_dark_theme() -> Theme {
83    Theme::new()
84        .with_block(
85            Block::default()
86                .borders(Borders::ALL)
87                .border_type(BorderType::Rounded)
88                .style(Style::default().fg(Color::White).bg(Color::Black)),
89        )
90        .with_item_style(Style::default().fg(Color::Yellow))
91        .with_dir_style(
92            Style::default()
93                .fg(Color::Cyan)
94                .add_modifier(Modifier::BOLD),
95        )
96        .with_highlight_symbol("> ")
97        .add_default_title()
98        .with_title_top(|_| Line::from(" ☾ Theme ").right_aligned())
99        .with_title_bottom(|_| " ^q Quit | ^s Switch theme ".into())
100}
Source

pub fn with_highlight_spacing(self, highlight_spacing: HighlightSpacing) -> Self

Set the spacing between the highlighted item and the other items.

Behind the scene, it use the List::highlight_spacing method. See its documentation for more.

§Example
let theme = Theme::default().with_highlight_spacing(HighlightSpacing::Never);
Source

pub fn with_title_top( self, title_top: impl Fn(&FileExplorer) -> Line<'static> + 'static, ) -> Self

Add a top title factory to the theme.

title_top is a function that take a reference to the current FileExplorer and returns a Line to be displayed as a title at the top of the wrapping block (if it exist) of the file explorer. You can call this function multiple times to add multiple titles.

Behind the scene, it use the Block::title_top method. See its documentation for more.

§Example
use ratatui::prelude::*;
let theme = Theme::default()
    .with_title_top(|file_explorer: &FileExplorer| {
        Line::from(format!("cwd - {}", file_explorer.cwd().display()))
    })
    .with_title_top(|file_explorer: &FileExplorer| {
        Line::from(format!("{} files", file_explorer.files().len() - 1)).right_aligned()
    });
Examples found in repository?
examples/light_and_dark_theme.rs (line 78)
62fn get_light_theme() -> Theme {
63    Theme::new()
64        .with_block(
65            Block::default()
66                .borders(Borders::ALL)
67                .border_type(BorderType::Rounded)
68                .style(Style::default().fg(Color::Black).bg(Color::White)),
69        )
70        .with_item_style(Style::default().fg(Color::Yellow))
71        .with_dir_style(
72            Style::default()
73                .fg(Color::Cyan)
74                .add_modifier(Modifier::BOLD),
75        )
76        .with_highlight_symbol("> ")
77        .add_default_title()
78        .with_title_top(|_| Line::from(" ☀ Theme ").right_aligned())
79        .with_title_bottom(|_| " ^q Quit | ^s Switch theme ".into())
80}
81
82fn get_dark_theme() -> Theme {
83    Theme::new()
84        .with_block(
85            Block::default()
86                .borders(Borders::ALL)
87                .border_type(BorderType::Rounded)
88                .style(Style::default().fg(Color::White).bg(Color::Black)),
89        )
90        .with_item_style(Style::default().fg(Color::Yellow))
91        .with_dir_style(
92            Style::default()
93                .fg(Color::Cyan)
94                .add_modifier(Modifier::BOLD),
95        )
96        .with_highlight_symbol("> ")
97        .add_default_title()
98        .with_title_top(|_| Line::from(" ☾ Theme ").right_aligned())
99        .with_title_bottom(|_| " ^q Quit | ^s Switch theme ".into())
100}
Source

pub fn with_title_bottom( self, title_bottom: impl Fn(&FileExplorer) -> Line<'static> + 'static, ) -> Self

Add a bottom title factory to the theme.

title_bottom is a function that take a reference to the current FileExplorer and returns a Line to be displayed as a title at the bottom of the wrapping block (if it exist) of the file explorer. You can call this function multiple times to add multiple titles.

Behind the scene, it use the Block::title_bottom method. See its documentation for more.

§Example
let theme = Theme::default()
    .with_title_bottom(|file_explorer: &FileExplorer| {
        Line::from(format!("cwd - {}", file_explorer.cwd().display()))
    })
    .with_title_bottom(|file_explorer: &FileExplorer| {
        Line::from(format!("{} files", file_explorer.files().len() - 1)).right_aligned()
    });
Examples found in repository?
examples/light_and_dark_theme.rs (line 79)
62fn get_light_theme() -> Theme {
63    Theme::new()
64        .with_block(
65            Block::default()
66                .borders(Borders::ALL)
67                .border_type(BorderType::Rounded)
68                .style(Style::default().fg(Color::Black).bg(Color::White)),
69        )
70        .with_item_style(Style::default().fg(Color::Yellow))
71        .with_dir_style(
72            Style::default()
73                .fg(Color::Cyan)
74                .add_modifier(Modifier::BOLD),
75        )
76        .with_highlight_symbol("> ")
77        .add_default_title()
78        .with_title_top(|_| Line::from(" ☀ Theme ").right_aligned())
79        .with_title_bottom(|_| " ^q Quit | ^s Switch theme ".into())
80}
81
82fn get_dark_theme() -> Theme {
83    Theme::new()
84        .with_block(
85            Block::default()
86                .borders(Borders::ALL)
87                .border_type(BorderType::Rounded)
88                .style(Style::default().fg(Color::White).bg(Color::Black)),
89        )
90        .with_item_style(Style::default().fg(Color::Yellow))
91        .with_dir_style(
92            Style::default()
93                .fg(Color::Cyan)
94                .add_modifier(Modifier::BOLD),
95        )
96        .with_highlight_symbol("> ")
97        .add_default_title()
98        .with_title_top(|_| Line::from(" ☾ Theme ").right_aligned())
99        .with_title_bottom(|_| " ^q Quit | ^s Switch theme ".into())
100}
Source

pub const fn block(&self) -> Option<&Block<'static>>

Returns the wrapping block (if it exist) of the file explorer of the theme.

Source

pub const fn style(&self) -> &Style

Returns the style of the widget of the theme.

Source

pub const fn item_style(&self) -> &Style

Returns the style of the non directories items of the theme.

Source

pub const fn dir_style(&self) -> &Style

Returns the style of the directories items of the theme.

Source

pub const fn highlight_item_style(&self) -> &Style

Returns the style of the highlighted non directories items of the theme.

Source

pub const fn highlight_dir_style(&self) -> &Style

Returns the style of the highlighted directories items of the theme.

Source

pub fn highlight_symbol(&self) -> Option<&str>

Returns the symbol used to highlight the selected item of the theme.

Source

pub const fn highlight_spacing(&self) -> &HighlightSpacing

Returns the spacing between the highlighted item and the other items of the theme.

Source

pub fn title_top(&self, file_explorer: &FileExplorer) -> Vec<Line<'_>>

Returns the generated top titles of the theme.

Source

pub fn title_bottom(&self, file_explorer: &FileExplorer) -> Vec<Line<'_>>

Returns the generated bottom titles of the theme.

Trait Implementations§

Source§

impl Clone for Theme

Source§

fn clone(&self) -> Theme

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 Theme

Source§

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

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

impl Default for Theme

Source§

fn default() -> Self

Return a slightly customized default theme. To get a theme with no style set, use Theme::new.

The theme will have a block with all borders, a white style for the items, a light blue style for the directories, a dark gray background for all the highlighted items.

§Example
let theme = Theme::default();
Source§

impl Hash for Theme

Source§

fn hash<__H>(&self, __state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Theme

Source§

fn eq(&self, other: &Self) -> 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 Eq for Theme

Auto Trait Implementations§

§

impl Freeze for Theme

§

impl !RefUnwindSafe for Theme

§

impl !Send for Theme

§

impl !Sync for Theme

§

impl Unpin for Theme

§

impl !UnwindSafe for Theme

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.