rat_text::text_area

Struct TextAreaState

Source
pub struct TextAreaState {
    pub area: Rect,
    pub inner: Rect,
    pub hscroll: ScrollState,
    pub vscroll: ScrollState,
    pub dark_offset: (u16, u16),
    pub value: TextCore<TextRope>,
    pub move_col: Option<upos_type>,
    pub auto_indent: bool,
    pub auto_quote: bool,
    pub focus: FocusFlag,
    pub mouse: MouseFlags,
    pub non_exhaustive: NonExhaustive,
}
Expand description

State & event handling.

Fields§

§area: Rect

The whole area with block. read only renewed with each render.

§inner: Rect

Area inside a possible block. read only renewed with each render.

§hscroll: ScrollState

Horizontal scroll read+write

§vscroll: ScrollState

Vertical offset read+write

§dark_offset: (u16, u16)

Dark offset due to clipping. read only secondary offset due to clipping.

§value: TextCore<TextRope>

Text edit core

§move_col: Option<upos_type>

movement column

§auto_indent: bool

auto indent active

§auto_quote: bool

quote selection active

§focus: FocusFlag

Current focus state.

§mouse: MouseFlags

Mouse selection in progress. read+write

§non_exhaustive: NonExhaustive

Implementations§

Source§

impl TextAreaState

Source

pub fn new() -> Self

New State.

Source

pub fn named(name: &str) -> Self

New state with a focus name.

Source

pub fn set_newline(&mut self, br: impl Into<String>)

Sets the line ending used for insert. There is no auto-detection or conversion done for set_value().

Caution: If this doesn’t match the line ending used in the value, you will get a value with mixed line endings.

Source

pub fn newline(&self) -> &str

Line ending used for insert.

Source

pub fn set_auto_indent(&mut self, indent: bool)

Sets auto-indent on new-line.

Source

pub fn set_auto_quote(&mut self, quote: bool)

Activates ‘add quotes to selection’.

Source

pub fn set_tab_width(&mut self, tabs: u16)

Set tab-width.

Source

pub fn tab_width(&self) -> u16

Tab-width

Source

pub fn set_expand_tabs(&mut self, expand: bool)

Expand tabs to spaces. Only for new inputs.

Source

pub fn expand_tabs(&self) -> bool

Expand tabs to spaces. Only for new inputs.

Source

pub fn set_show_ctrl(&mut self, show_ctrl: bool)

Show control characters.

Source

pub fn show_ctrl(&self) -> bool

Show control characters.

Source

pub fn set_move_col(&mut self, col: Option<upos_type>)

Extra column information for cursor movement.

The cursor position is capped to the current line length, so if you move up one row, you might end at a position left of the current column. If you move up once more you want to return to the original position. That’s what is stored here.

Source

pub fn move_col(&mut self) -> Option<upos_type>

Extra column information for cursor movement.

Source§

impl TextAreaState

Source

pub fn set_clipboard(&mut self, clip: Option<impl Clipboard + 'static>)

Clipboard

Source

pub fn clipboard(&self) -> Option<&dyn Clipboard>

Clipboard

Source

pub fn copy_to_clip(&mut self) -> bool

Copy to internal buffer

Source

pub fn cut_to_clip(&mut self) -> bool

Cut to internal buffer

Source

pub fn paste_from_clip(&mut self) -> bool

Paste from internal buffer.

Source§

impl TextAreaState

Source

pub fn set_undo_buffer(&mut self, undo: Option<impl UndoBuffer + 'static>)

Set undo buffer.

Source

pub fn undo_buffer(&self) -> Option<&dyn UndoBuffer>

Undo

Source

pub fn undo_buffer_mut(&mut self) -> Option<&mut dyn UndoBuffer>

Undo

Source

pub fn begin_undo_seq(&mut self)

Begin a sequence of changes that should be undone in one go.

Source

pub fn end_undo_seq(&mut self)

End a sequence of changes that should be undone in one go.

Source

pub fn recent_replay_log(&mut self) -> Vec<UndoEntry>

Get all recent replay recordings.

Source

pub fn replay_log(&mut self, replay: &[UndoEntry])

Apply the replay recording.

Source

pub fn undo(&mut self) -> bool

Undo operation

Source

pub fn redo(&mut self) -> bool

Redo operation

Source§

impl TextAreaState

Source

pub fn set_styles(&mut self, styles: Vec<(Range<usize>, usize)>)

Set and replace all styles.

Source

pub fn add_style(&mut self, range: Range<usize>, style: usize)

Add a style for a TextRange. The style-nr refers to one of the styles set with the widget.

Source

pub fn add_range_style( &mut self, range: TextRange, style: usize, ) -> Result<(), TextError>

Add a style for a TextRange. The style-nr refers to one of the styles set with the widget.

Source

pub fn remove_style(&mut self, range: Range<usize>, style: usize)

Remove the exact TextRange and style.

Source

pub fn remove_range_style( &mut self, range: TextRange, style: usize, ) -> Result<(), TextError>

Remove the exact TextRange and style.

Source

pub fn styles_in( &self, range: Range<usize>, buf: &mut Vec<(Range<usize>, usize)>, )

Find all styles that touch the given range.

Source

pub fn styles_at(&self, byte_pos: usize, buf: &mut Vec<(Range<usize>, usize)>)

All styles active at the given position.

Source

pub fn style_match(&self, byte_pos: usize, style: usize) -> Option<Range<usize>>

Check if the given style applies at the position and return the complete range for the style.

Source

pub fn styles(&self) -> impl Iterator<Item = (Range<usize>, usize)> + '_

List of all styles.

Source§

impl TextAreaState

Source

pub fn offset(&self) -> (usize, usize)

Current offset for scrolling.

Source

pub fn set_offset(&mut self, offset: (usize, usize)) -> bool

Set the offset for scrolling.

Source

pub fn cursor(&self) -> TextPosition

Cursor position.

Source

pub fn set_cursor( &mut self, cursor: impl Into<TextPosition>, extend_selection: bool, ) -> bool

Set the cursor position. This doesn’t scroll the cursor to a visible position. Use TextAreaState::scroll_cursor_to_visible() for that.

Source

pub fn anchor(&self) -> TextPosition

Selection anchor.

Source

pub fn has_selection(&self) -> bool

Has a selection?

Source

pub fn selection(&self) -> TextRange

Current selection.

Source

pub fn set_selection( &mut self, anchor: impl Into<TextPosition>, cursor: impl Into<TextPosition>, ) -> bool

Set the selection.

Source

pub fn select_all(&mut self) -> bool

Select all.

Source

pub fn selected_text(&self) -> Cow<'_, str>

Selection.

Source§

impl TextAreaState

Source

pub fn is_empty(&self) -> bool

Empty.

Source

pub fn rope(&self) -> &Rope

Borrow the rope

Source

pub fn text(&self) -> String

Text value

Source

pub fn str_slice_byte(&self, range: Range<usize>) -> Cow<'_, str>

Text slice as Cow<str>. Uses a byte range.

Source

pub fn try_str_slice_byte( &self, range: Range<usize>, ) -> Result<Cow<'_, str>, TextError>

Text slice as Cow<str>. Uses a byte range.

Source

pub fn str_slice(&self, range: impl Into<TextRange>) -> Cow<'_, str>

Text slice as Cow<str>

Source

pub fn try_str_slice( &self, range: impl Into<TextRange>, ) -> Result<Cow<'_, str>, TextError>

Text slice as Cow<str>

Source

pub fn len_lines(&self) -> upos_type

Line count.

Source

pub fn line_width(&self, row: upos_type) -> upos_type

Line width as grapheme count.

Source

pub fn try_line_width(&self, row: upos_type) -> Result<upos_type, TextError>

Line width as grapheme count.

Source

pub fn line_at(&self, row: upos_type) -> Cow<'_, str>

Line as RopeSlice. This contains the \n at the end.

Source

pub fn try_line_at(&self, row: upos_type) -> Result<Cow<'_, str>, TextError>

Line as RopeSlice. This contains the \n at the end.

Source

pub fn lines_at(&self, row: upos_type) -> impl Iterator<Item = Cow<'_, str>>

Iterate over text-lines, starting at offset.

Source

pub fn try_lines_at( &self, row: upos_type, ) -> Result<impl Iterator<Item = Cow<'_, str>>, TextError>

Iterate over text-lines, starting at offset.

Source

pub fn glyphs( &self, rows: Range<upos_type>, screen_offset: u16, screen_width: u16, ) -> impl Iterator<Item = Glyph<'_>>

Glyphs here a grapheme + display length.

Source

pub fn try_glyphs( &self, rows: Range<upos_type>, screen_offset: u16, screen_width: u16, ) -> Result<impl Iterator<Item = Glyph<'_>>, TextError>

Glyphs here a grapheme + display length.

Source

pub fn line_graphemes( &self, row: upos_type, ) -> impl Iterator<Item = Grapheme<'_>>

Grapheme iterator for a given line. This contains the \n at the end.

Source

pub fn try_line_graphemes( &self, row: upos_type, ) -> Result<impl Iterator<Item = Grapheme<'_>>, TextError>

Grapheme iterator for a given line. This contains the \n at the end.

Source

pub fn text_graphemes( &self, pos: TextPosition, ) -> impl Cursor<Item = Grapheme<'_>>

Get a cursor over all the text with the current position set at pos.

Source

pub fn try_text_graphemes( &self, pos: TextPosition, ) -> Result<impl Cursor<Item = Grapheme<'_>>, TextError>

Get a cursor over all the text with the current position set at pos.

Source

pub fn graphemes( &self, range: TextRange, pos: TextPosition, ) -> impl Cursor<Item = Grapheme<'_>>

Get a cursor over the text-range the current position set at pos.

Source

pub fn try_graphemes( &self, range: TextRange, pos: TextPosition, ) -> Result<impl Cursor<Item = Grapheme<'_>>, TextError>

Get a cursor over the text-range the current position set at pos.

Source

pub fn byte_at(&self, pos: TextPosition) -> Range<usize>

Grapheme position to byte position. This is the (start,end) position of the single grapheme after pos.

Source

pub fn try_byte_at(&self, pos: TextPosition) -> Result<Range<usize>, TextError>

Grapheme position to byte position. This is the (start,end) position of the single grapheme after pos.

Source

pub fn try_bytes_at_range( &self, range: TextRange, ) -> Result<Range<usize>, TextError>

Grapheme range to byte range.

Source

pub fn bytes_at_range(&self, range: TextRange) -> Range<usize>

Grapheme range to byte range.

Source

pub fn byte_pos(&self, byte: usize) -> TextPosition

Byte position to grapheme position. Returns the position that contains the given byte index.

Source

pub fn try_byte_pos(&self, byte: usize) -> Result<TextPosition, TextError>

Byte position to grapheme position. Returns the position that contains the given byte index.

Source

pub fn byte_range(&self, bytes: Range<usize>) -> TextRange

Byte range to grapheme range.

Source

pub fn try_byte_range( &self, bytes: Range<usize>, ) -> Result<TextRange, TextError>

Byte range to grapheme range.

Source§

impl TextAreaState

Source

pub fn clear(&mut self) -> bool

Clear everything.

Source

pub fn set_text<S: AsRef<str>>(&mut self, s: S)

Set the text value. Resets all internal state.

Source

pub fn set_rope(&mut self, r: Rope)

Set the text value as a Rope. Resets all internal state.

Source

pub fn insert_char(&mut self, c: char) -> bool

Insert a character at the cursor position. Removes the selection and inserts the char.

This insert makes no special actions when encountering a new-line or tab. Use insert_newline and insert_tab for this.

Source

pub fn insert_tab(&mut self) -> bool

Inserts tab at the current position. This respects the tab-width set.

If there is a text-selection the text-rows will be indented instead. This can be deactivated with auto_indent=false.

Source

pub fn insert_backtab(&mut self) -> bool

Unindents the selected text by tab-width. If there is no selection this does nothing.

This can be deactivated with auto_indent=false.

Source

pub fn insert_str(&mut self, t: impl AsRef<str>) -> bool

Insert text at the cursor position. Removes the selection and inserts the text.

Source

pub fn insert_newline(&mut self) -> bool

Insert a line break at the cursor position.

If auto_indent is set the new line starts with the same indent as the current.

Source

pub fn delete_range(&mut self, range: impl Into<TextRange>) -> bool

Deletes the given range.

Source

pub fn try_delete_range( &mut self, range: impl Into<TextRange>, ) -> Result<bool, TextError>

Deletes the given range.

Source§

impl TextAreaState

Source

pub fn duplicate_text(&mut self) -> bool

Duplicates the selection or the current line. Returns true if there was any real change.

Source

pub fn delete_line(&mut self) -> bool

Deletes the current line. Returns true if there was any real change.

Source

pub fn delete_next_char(&mut self) -> bool

Deletes the next char or the current selection. Returns true if there was any real change.

Source

pub fn delete_prev_char(&mut self) -> bool

Deletes the previous char or the selection. Returns true if there was any real change.

Source

pub fn next_word_start(&self, pos: impl Into<TextPosition>) -> TextPosition

Find the start of the next word. If the position is at the start or inside a word, the same position is returned.

Source

pub fn try_next_word_start( &self, pos: impl Into<TextPosition>, ) -> Result<TextPosition, TextError>

Find the start of the next word. If the position is at the start or inside a word, the same position is returned.

Source

pub fn next_word_end(&self, pos: impl Into<TextPosition>) -> TextPosition

Find the end of the next word. Skips whitespace first, then goes on until it finds the next whitespace.

Source

pub fn try_next_word_end( &self, pos: impl Into<TextPosition>, ) -> Result<TextPosition, TextError>

Find the end of the next word. Skips whitespace first, then goes on until it finds the next whitespace.

Source

pub fn prev_word_start(&self, pos: impl Into<TextPosition>) -> TextPosition

Find the start of the prev word. Skips whitespace first, then goes on until it finds the next whitespace.

Attention: start/end are mirrored here compared to next_word_start/next_word_end, both return start<=end!

Source

pub fn try_prev_word_start( &self, pos: impl Into<TextPosition>, ) -> Result<TextPosition, TextError>

Find the start of the prev word. Skips whitespace first, then goes on until it finds the next whitespace.

Attention: start/end are mirrored here compared to next_word_start/next_word_end, both return start<=end!

Source

pub fn prev_word_end(&self, pos: impl Into<TextPosition>) -> TextPosition

Find the end of the previous word. Word is everything that is not whitespace. Attention: start/end are mirrored here compared to next_word_start/next_word_end, both return start<=end!

Source

pub fn try_prev_word_end( &self, pos: impl Into<TextPosition>, ) -> Result<TextPosition, TextError>

Find the end of the previous word. Word is everything that is not whitespace. Attention: start/end are mirrored here compared to next_word_start/next_word_end, both return start<=end!

Source

pub fn is_word_boundary(&self, pos: impl Into<TextPosition>) -> bool

Is the position at a word boundary?

Source

pub fn try_is_word_boundary( &self, pos: impl Into<TextPosition>, ) -> Result<bool, TextError>

Is the position at a word boundary?

Source

pub fn word_start(&self, pos: impl Into<TextPosition>) -> TextPosition

Find the start of the word at pos. Returns pos if the position is not inside a word.

Source

pub fn try_word_start( &self, pos: impl Into<TextPosition>, ) -> Result<TextPosition, TextError>

Find the start of the word at pos. Returns pos if the position is not inside a word.

Source

pub fn word_end(&self, pos: impl Into<TextPosition>) -> TextPosition

Find the end of the word at pos. Returns pos if the position is not inside a word.

Source

pub fn try_word_end( &self, pos: impl Into<TextPosition>, ) -> Result<TextPosition, TextError>

Find the end of the word at pos. Returns pos if the position is not inside a word.

Source

pub fn delete_next_word(&mut self) -> bool

Delete the next word. This alternates deleting the whitespace between words and the words themselves.

Source

pub fn delete_prev_word(&mut self) -> bool

Deletes the previous word. This alternates deleting the whitespace between words and the words themselves.

Source

pub fn move_left(&mut self, n: upos_type, extend_selection: bool) -> bool

Move the cursor left. Scrolls the cursor to visible. Returns true if there was any real change.

Source

pub fn move_right(&mut self, n: upos_type, extend_selection: bool) -> bool

Move the cursor right. Scrolls the cursor to visible. Returns true if there was any real change.

Source

pub fn move_up(&mut self, n: upos_type, extend_selection: bool) -> bool

Move the cursor up. Scrolls the cursor to visible. Returns true if there was any real change.

Source

pub fn move_down(&mut self, n: upos_type, extend_selection: bool) -> bool

Move the cursor down. Scrolls the cursor to visible. Returns true if there was any real change.

Source

pub fn move_to_line_start(&mut self, extend_selection: bool) -> bool

Move the cursor to the start of the line. Scrolls the cursor to visible. Returns true if there was any real change.

Source

pub fn move_to_line_end(&mut self, extend_selection: bool) -> bool

Move the cursor to the end of the line. Scrolls to visible, if necessary. Returns true if there was any real change.

Source

pub fn move_to_start(&mut self, extend_selection: bool) -> bool

Move the cursor to the document start.

Source

pub fn move_to_end(&mut self, extend_selection: bool) -> bool

Move the cursor to the document end.

Source

pub fn move_to_screen_start(&mut self, extend_selection: bool) -> bool

Move the cursor to the start of the visible area.

Source

pub fn move_to_screen_end(&mut self, extend_selection: bool) -> bool

Move the cursor to the end of the visible area.

Source

pub fn move_to_next_word(&mut self, extend_selection: bool) -> bool

Move the cursor to the next word.

Source

pub fn move_to_prev_word(&mut self, extend_selection: bool) -> bool

Move the cursor to the previous word.

Source§

impl TextAreaState

Source

pub fn screen_to_row(&self, scy: i16) -> upos_type

Converts from a widget relative screen coordinate to a line. It limits its result to a valid row.

Source

pub fn screen_to_col(&self, row: upos_type, scx: i16) -> upos_type

Converts from a widget relative screen coordinate to a grapheme index. It limits its result to a valid column.

  • row is a row-index into the value, not a screen-row. It can be calculated with screen_to_row().
  • x is the relative screen position.
Source

pub fn try_screen_to_col( &self, row: upos_type, scx: i16, ) -> Result<upos_type, TextError>

Converts from a widget relative screen coordinate to a grapheme index. It limits its result to a valid column.

  • row is a row-index into the value, not a screen-row. It can be calculated with screen_to_row().
  • x is the relative screen position.
Source

pub fn row_to_screen(&self, pos: impl Into<TextPosition>) -> Option<u16>

Converts the row of the position to a screen position relative to the widget area.

Source

pub fn col_to_screen(&self, pos: impl Into<TextPosition>) -> Option<u16>

Converts a grapheme based position to a screen position relative to the widget area.

Source

pub fn try_col_to_screen( &self, pos: impl Into<TextPosition>, ) -> Result<Option<u16>, TextError>

Converts a grapheme based position to a screen position relative to the widget area.

Source

pub fn set_screen_cursor( &mut self, cursor: (i16, i16), extend_selection: bool, ) -> bool

Set the cursor position from screen coordinates.

The cursor positions are relative to the inner rect. They may be negative too, this allows setting the cursor to a position that is currently scrolled away.

Source

pub fn set_screen_cursor_words( &mut self, cursor: (i16, i16), extend_selection: bool, ) -> bool

Set the cursor position from screen coordinates, rounds the position to the next word start/end.

The cursor positions are relative to the inner rect. They may be negative too, this allows setting the cursor to a position that is currently scrolled away.

Source§

impl TextAreaState

Source

pub fn vertical_max_offset(&self) -> usize

Maximum offset that is accessible with scrolling.

This is shorter than the length of the content by whatever fills the last page. This is the base for the scrollbar content_length.

Source

pub fn vertical_offset(&self) -> usize

Current vertical offset.

Source

pub fn vertical_page(&self) -> usize

Vertical page-size at the current offset.

Source

pub fn vertical_scroll(&self) -> usize

Suggested scroll per scroll-event.

Source

pub fn horizontal_max_offset(&self) -> usize

Maximum offset that is accessible with scrolling.

This is currently set to usize::MAX.

Source

pub fn horizontal_offset(&self) -> usize

Current horizontal offset.

Source

pub fn horizontal_page(&self) -> usize

Horizontal page-size at the current offset.

Source

pub fn horizontal_scroll(&self) -> usize

Suggested scroll per scroll-event.

Source

pub fn set_vertical_offset(&mut self, row_offset: usize) -> bool

Change the vertical offset.

Due to overscroll it’s possible that this is an invalid offset for the widget. The widget must deal with this situation.

The widget returns true if the offset changed at all.

Source

pub fn set_horizontal_offset(&mut self, col_offset: usize) -> bool

Change the horizontal offset.

Due to overscroll it’s possible that this is an invalid offset for the widget. The widget must deal with this situation.

The widget returns true if the offset changed at all.

Source

pub fn scroll_to_row(&mut self, pos: usize) -> bool

Scroll to position.

Source

pub fn scroll_to_col(&mut self, pos: usize) -> bool

Scroll to position.

Source

pub fn scroll_up(&mut self, delta: usize) -> bool

Scrolling

Source

pub fn scroll_down(&mut self, delta: usize) -> bool

Scrolling

Source

pub fn scroll_left(&mut self, delta: usize) -> bool

Scrolling

Source

pub fn scroll_right(&mut self, delta: usize) -> bool

Scrolling

Source§

impl TextAreaState

Source

pub fn scroll_cursor_to_visible(&mut self) -> bool

Scroll that the cursor is visible. All move-fn do this automatically.

Trait Implementations§

Source§

impl Clone for TextAreaState

Source§

fn clone(&self) -> Self

Returns a copy 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 TextAreaState

Source§

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

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

impl Default for TextAreaState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl HandleEvent<Event, MouseOnly, TextOutcome> for TextAreaState

Source§

fn handle(&mut self, event: &Event, _keymap: MouseOnly) -> TextOutcome

Handle an event. Read more
Source§

impl HandleEvent<Event, ReadOnly, TextOutcome> for TextAreaState

Source§

fn handle(&mut self, event: &Event, _keymap: ReadOnly) -> TextOutcome

Handle an event. Read more
Source§

impl HandleEvent<Event, Regular, TextOutcome> for TextAreaState

Source§

fn handle(&mut self, event: &Event, _keymap: Regular) -> TextOutcome

Handle an event. Read more
Source§

impl HasFocus for TextAreaState

Source§

fn focus(&self) -> FocusFlag

Access to the flag for the rest.
Source§

fn area(&self) -> Rect

Area for mouse focus. Read more
Source§

fn navigable(&self) -> Navigation

Declares how the widget interacts with focus. Read more
Source§

fn build(&self, builder: &mut FocusBuilder)

Build the focus-structure for the container.
Source§

fn z_areas(&self) -> &[ZRect]

The widget might have several disjointed/overlapping areas. This is the case if it is showing a popup, but there might be other causes. Read more
Source§

fn is_focused(&self) -> bool

Focused?
Source§

fn lost_focus(&self) -> bool

Just lost focus.
Source§

fn gained_focus(&self) -> bool

Just gained focus.
Source§

impl HasScreenCursor for TextAreaState

Source§

fn screen_cursor(&self) -> Option<(u16, u16)>

Cursor position on the screen.

Source§

impl RelocatableState for TextAreaState

Source§

fn relocate(&mut self, shift: (i16, i16), clip: Rect)

Relocate the areas in this widgets state.

Auto Trait Implementations§

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, dst: *mut T)

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

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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.