Guide API
Skip to main content

Window

Struct Window 

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

A framed, selectable window: a Group that builds a Frame around itself.

Build with Window::new, then drive it as any other View.

§Turbo Vision heritage

Ports TWindow (twindow.cpp). The base-class container becomes an embedded Group (deviation D2); the window pushes the frame’s data down rather than letting the frame reach up (deviation D3).

Implementations§

Source§

impl Window

Source

pub const MIN_WIN_SIZE: Point

The absolute minimum a framed window may shrink to and still render its title bar and corner icons legibly. Ports minWinSize (twindow.cpp:30). The default size_limits minimum; a larger floor can be set with set_min_size.

Source

pub fn new(bounds: Rect, title: Option<String>, number: i16) -> Self

Construct a window over bounds with an optional title and a window number.

number: pass a positive value (1–9) to make the window reachable via the Alt-N keyboard shortcut; Program broadcasts Command::SELECT_WINDOW_NUM and the desktop finds the matching window by its number. Pass 0 (the wnNoNumber sentinel from Turbo Vision) for an unnumbered window that is never a select-by-number target — this is the common case for document windows that are cycled with NEXT/PREV instead of by number.

Defaults set at construction: all four decoration flags enabled (move/grow/close/zoom); not maximized (no restore rect) and bordered; the blue colour scheme; a drop shadow; selectable + top-of-select-group; and a relative grow-all mode (children resize proportionally with the window).

Frame data is pushed down at construction. We build the Frame concretely so we can call its owner-data-down setters (set_title/set_flags/ set_number) before boxing + inserting.

A frame is mandatory: frame_id is non-optional. A frameless variant has no consumer here, and supporting it would force an Option<ViewId> ripple for a path no caller exercises, so we always build the frame.

Source

pub fn frame_id(&self) -> ViewId

The ViewId of the Frame child that draws the window border, title, and icons.

Use this id to reach the frame via child_mut + downcast when you need to call a frame-specific method (e.g. to read Frame::zoomed). The window itself never holds a direct &mut Frame reference across calls; instead it always resolves the id on demand — the push-down pattern that avoids upward parent pointers.

Source

pub fn flags(&self) -> WindowFlags

The current decoration flags (which of move / grow / close / zoom are enabled).

Read these to check which operations the window permits; for example, flags().zoom is true when the zoom icon is shown and the zoom command is accepted. To change the flags after construction use set_flags (crate-internal).

Source

pub fn restore_rect(&self) -> Option<Rect>

The saved pre-maximize bounds, or None when the window is not maximized.

maximize stores the current bounds here before growing to fill the owner; restore consumes them. This is the single restore slot shared by the ZOOM command and fullscreen-Desktop. Primarily useful for testing; normal application code reads is_maximized instead.

Source

pub fn is_maximized(&self) -> bool

Whether the window is currently maximized (filling its owner via maximize). Equivalent to restore_rect().is_some().

Source

pub fn bordered(&self) -> bool

Whether the frame border is drawn. An independent primitive (decoupled from fullscreen); toggle with set_bordered.

Source

pub fn palette(&self) -> WindowPalette

The colour scheme used to draw this window’s frame.

Plain windows use WindowPalette::Blue (the default); dialogs use WindowPalette::Gray (set automatically by Dialog). Inspect this to branch on the active scheme; to change it after construction use set_palette (crate-internal).

Source

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

The window title displayed in the frame’s title bar, or None for an untitled window.

Pass the title at construction via Window::new. To rename the window after construction (e.g. after a save-as), use set_title (crate-internal), which updates both this field and the frame child. The frame truncates the title to the available title-bar width at draw time; no explicit length limit is needed here.

Source

pub fn fullscreen(&self) -> Fullscreen

The window’s current Fullscreen state.

Source

pub fn set_flags(&mut self, flags: WindowFlags)

Override the decoration flags after construction. Re-pushes to the frame child: construction pushes the flags once, so a later change must re-push or the frame would still draw the original zoom/grow icons. Resolves the frame child then downcasts then calls Frame::set_flags, the same seam zoom uses.

Source

pub fn set_palette(&mut self, palette: WindowPalette)

Override the colour scheme after construction. Re-pushes to the frame child (the set_flags pattern) so the frame renders the matching role family: Blue → Role::Frame*, Cyan → Role::FrameCyan*, Gray → Role::FrameGray*.

Source

pub fn set_grow_mode(&mut self, grow_mode: GrowMode)

Override the grow mode after construction (a dialog uses an empty grow mode — it does not track its owner’s resize).

Source

pub fn set_drag_mode(&mut self, drag_mode: DragMode)

Override the drag mode after construction (the screen-edge limits the window honors while being dragged). Mirrors set_grow_mode: a plain write to the embedded group’s ViewState::drag_mode.

Source

pub fn set_min_size(&mut self, min: Point)

Raise the window’s interactive-resize floor. The argument is clamped up to at least Self::MIN_WIN_SIZE per axis (title/icons must stay legible), so this can only grow the minimum. Consulted by every size-clamp path — mouse corner drag, keyboard resize, ZOOM/restore, owner-driven resize — via size_limits.

§Turbo Vision heritage

In C++ a window subclass raises its floor by overriding the virtual sizeLimits (e.g. TFileDialog, TEditWindow), which every clamp path calls virtually. Embed-and-delegate composition (D2) has no upward dispatch, so the wrapper pushes its floor down into the window instead.

Source

pub fn with_flags(self, flags: WindowFlags) -> Self

Builder form of set_flags.

Source

pub fn with_palette(self, palette: WindowPalette) -> Self

Builder form of set_palette.

Source

pub fn with_grow_mode(self, grow_mode: GrowMode) -> Self

Builder form of set_grow_mode.

Source

pub fn with_drag_mode(self, drag_mode: DragMode) -> Self

Builder form of set_drag_mode.

Source

pub fn with_min_size(self, min: Point) -> Self

Builder form of set_min_size.

Source

pub fn insert_child(&mut self, view: Box<dyn View>) -> ViewId

Insert a child view into the embedded group.

Used by the history window (which inserts the history viewer after the scroll bars), by Dialog, and by the message box.

Exposed publicly so that example/application code can build custom windows with child views.

Source

pub fn child_mut(&mut self, id: ViewId) -> Option<&mut dyn View>

Reach a direct child of the embedded group by id.

Used by the history window to run the viewer’s post-insert setup and to read its selection via as_any_mut + downcast. Mirrors Group::child_mut without exposing the group itself.

Source

pub fn gather_list(&self) -> FieldValue

Gather the embedded group’s whole record as one ordered FieldValue::List. Forwards to Group::gather_list.

Source

pub fn scatter_list(&mut self, record: &FieldValue, ctx: &mut Context<'_>)

Scatter an ordered FieldValue::List record back into the embedded group. Forwards to Group::scatter_list.

Source

pub fn client_rect(&self) -> Rect

The window’s interior content rectangle (view-local). Inset by the frame border when bordered. Scroll-bar lanes are always excluded — the right column when a vertical bar is present, the bottom row when a horizontal bar is present — so placing content at client_rect never overlaps the bars regardless of border state. Apps placing window content should key off this rather than hardcoding the frame inset.

Source

pub fn set_bordered(&mut self, bordered: bool, ctx: &mut Context<'_>)

Show or hide the frame border, reflowing content to the new client area.

Border visibility is an independent primitive (decoupled from fullscreen and maximize). Toggling it:

  1. flips the Frame’s border_visible (the inline downcast seam — the only path that reaches the frame), and
  2. reflows content via reflow_client: the client area grows/shrinks by the border thickness, so each content child reacts through its existing grow_mode plus a (∓1, ∓1) origin shift, exactly as on a normal resize. Owned scroll bars are re-derived from the client_rect formula (they are chrome, not content).

Idempotent if bordered is unchanged.

Source

pub fn set_fullscreen(&mut self, mode: Fullscreen, ctx: &mut Context<'_>)

Set the window’s frameless-fullscreen mode by composing the independent primitives:

  • Off → restore (un-maximize) + re-border.
  • Desktop / Screen → maximize + drop the border.

The window-local work (maximize/restore + border + content reflow) is done inline (the pump cannot downcast to Window); the emitted Deferred::SetFullscreen tells the pump to do the cross-tree work (menu bar / desktop) and to track the window for resize re-fit and removal-restore.

§Turbo Vision heritage

tvision-rs extension to TWindow.

Source

pub fn standard_scroll_bar(&mut self, opts: ScrollBarOptions) -> ViewId

Insert a standard scroll bar on the right or bottom edge and return its ViewId.

Pass ScrollBarOptions to choose vertical (right edge) or horizontal (bottom edge) placement, and whether the bar handles keyboard arrow keys when it is not the focused view (handle_keyboard).

The bar is sized to fit exactly inside the frame without covering the frame corners:

  • Vertical (right edge): one cell wide, flush against the right frame edge. Bordered: (width−1, 1) .. (width, height−1) (frame-corner inset). Frameless: spans from the top screen edge to the bottom, stopping one row above the horizontal bar’s row when both bars are present.
  • Horizontal (bottom edge): one cell tall. Bordered: (2, height−1) .. (width−2, height) (frame-corner inset). Frameless: starts at the left screen edge and runs to just before the vertical bar’s column when both bars are present (no left inset).

Call this method after construction and before the window is shown. The returned ViewId can be passed to a scroller or list viewer as its linked scroll bar.

For handle_keyboard, post-processing is enabled on the ScrollBar before boxing + inserting (the insert call consumes the box, so the flag must be set first).

Source

pub fn maximize(&mut self, ctx: &mut Context<'_>)

Grow the window to fill its owner, saving the pre-maximize bounds into the single restore_rect slot (if not already maximized).

The maximum size (the owner’s size) is reached via the owner-extent-down channel (Context::owner_size) instead of an up-pointer. The window’s own size_limits override (max = owner size, min = min_size, default 16×6) is used. Shared by the ZOOM command and fullscreen-Desktop, so they cannot desync.

Source

pub fn restore(&mut self, ctx: &mut Context<'_>)

Restore the window to its saved pre-maximize bounds (consuming the restore_rect slot). A no-op on the bounds if the window was not maximized; always clears the frame’s zoomed icon.

Trait Implementations§

Source§

impl View for Window

Source§

fn draw(&mut self, ctx: &mut DrawCtx<'_>)

Always delegates the draw to the group; first, if this window hosts a Splitter body, it reads that splitter’s divider abutment marks (parent→child) and pushes them to the frame child (owner-data-down) so the frame composes connected tees. The marks are empty unless the splitter opted in via Splitter::joined, so a plain window — or one whose splitter is not joined — is byte-for-byte unchanged (an empty mark set reverts the frame to a plain border). Both child borrows are sequential (the marks Vec is owned between them, so only one &mut child is live at a time).

Source§

fn handle_event(&mut self, ev: &mut Event, ctx: &mut Context<'_>)

Delegate to the group first, then handle the window’s own commands and the focus-cycling keys:

  • zoom command (if zoom is allowed) → maximize / restore through the single restore slot + consume. No “is this the right window?” target guard is needed here: it is provably vacuous in this architecture. The frame emits the zoom/close commands only while it is active, so the target is always the active window; these are focused command events, which the desktop routes solely to its current child = the active window; and the internal queue drains fully before the next event poll, so the active window cannot change between emit and dispatch. A zoom/close therefore always reaches exactly the window it targets. Trip-wire: revisit only if a future emitter targets a non-active window via a command.
  • close command (if close is allowed) → request_close (the loop drains it into remove_descendant), or post a cancel command if modal. Same vacuous target-guard reasoning as zoom. The modal-cancel branch is wired here; the broader modal teardown lives in the dialog layer.
  • Tab → cycle focus forward + consume.
  • Shift+Tab → cycle focus backward + consume. Shift+Tab is Key::Tab + the shift modifier (there is no separate back-tab key).
  • A surviving title-bar / bottom-corner / middle-button MouseDown → start_drag (which pushes a DragCapture).
  • resize command → enable the Dragging flag and push a KeyboardResizeCapture that handles arrow keys until Enter (accept) or Esc (restore). The resize command is enabled in set_state when the window is selected and move or grow is allowed.
  • select-window-by-number is not handled here. The window number is an integer argument, so the broadcast-source substrate does not serve it; instead program_handle_event asks the desktop (Desktop::select_window_num) to select the child whose number matches (Group::focus_by_number).
Source§

fn set_state(&mut self, flag: StateFlag, enable: bool, ctx: &mut Context<'_>)

The activation half of state changes.

Delegate to Group::set_state (flips the flag + propagates to children), then — iff the Selected flag is being set — also set the Active flag on the group. That Active propagation flips every child (incl. the frame) active / passive, so the frame does not need to be pushed manually.

On selection, the window-command set is enabled (and disabled on deselection):

  • next/prev window: unconditional (handled by the desktop).
  • zoom: if zoom is allowed (handled in handle_event).
  • close: if close is allowed (handled in handle_event).
  • resize: if move or grow is allowed (handled in handle_event → KeyboardResizeCapture).
Source§

fn size_limits(&self, owner_size: Point) -> (Point, Point)

The window’s size limits: the owner-derived maximum with the minimum forced to min_size (defaults to Self::MIN_WIN_SIZE, 16×6) — the smallest a window can be while still showing its frame icons legibly.

This size_limits override is intentionally not in the #[delegate] skip list, while calc_bounds is skipped: calc_bounds therefore routes through the trait default, which calls this size_limits override (giving the min_size floor, default 16×6). If calc_bounds were delegated to the inner Group, it would use the group’s own size_limits (min 0×0) and silently bypass the window minimum on owner-driven resizes.

Source§

fn number(&self) -> Option<i16>

The window number (1–9), or None for an unnumbered window.

A positive number makes the window reachable by Alt+N (where N is the digit). The program’s event handler broadcasts cmSelectWindowNum and the desktop walks its children calling View::number() on each; the first window whose number matches N is focused (Group::focus_by_number). A window constructed with number == 0 (or any non-positive value) returns None and is never a select-by-number target.

Source§

fn as_any_mut(&mut self) -> Option<&mut dyn Any>

Concrete-reach hook so the pump’s fullscreen layout engine can push the kebab-reservation flag (via the crate-internal set_menu_chrome_above). Mirrors the menu-bar collapse downcast; without it the engine cannot reach a Window behind &mut dyn View.

Source§

fn state(&self) -> &ViewState

Borrow the embedded ViewState (the view’s data members).
Source§

fn state_mut(&mut self) -> &mut ViewState

Mutably borrow the embedded ViewState.
Source§

fn valid(&mut self, cmd: Command, ctx: &mut Context<'_>) -> bool

Whether the view is in a valid state for cmd (e.g. a modal end / focus release). Base is always true. Read more
Source§

fn set_modal_answer(&mut self, cmd: Command)

Stash the user’s choice from an async modal message box this view requested via Context::request_message_box (the answer_to/RouteModalAnswer round-trip). Default: no-op. Overridden by views that drive a Yes/No/Cancel prompt out of valid (e.g. FileEditor caches it for the re-validate).
Source§

fn set_modal_data(&mut self, data: FieldValue)

Deliver a finished modal’s typed result record to the view that launched it. Defaulted no-op; a launcher view overrides it to load the record. Two producers call it: Read more
Source§

fn set_value_ctx(&mut self, v: FieldValue, ctx: &mut Context<'_>)

Scatter a typed FieldValue into this control with a Context. Default: calls set_value (the context-free setter). Override when scatter needs deferred publishing (e.g. ListBox republishes its vertical scrollbar via focus_item).
Source§

fn awaken(&mut self)

Post-construction initialization hook. Called once after the view has been inserted into its group and the group’s layout is complete — the earliest point at which a view may safely resolve sibling ids or run initialization that requires a fully-wired tree. Override when a widget needs to do work that cannot happen during construction (e.g. reading a linked control’s current value). Base is a no-op.
Source§

fn change_bounds(&mut self, bounds: Rect)

Apply bounds to this view and propagate as needed. Read more
Source§

fn on_bounds_changed(&mut self, ctx: &mut Context<'_>)

Called by the pump after change_bounds is applied via Deferred::ChangeBounds — provides a Context for re-publishing state that depends on the new bounds (e.g. scrollbar params). Default implementation is a no-op. Read more
Source§

fn cursor_request(&self) -> Option<Point>

The view-local hardware-cursor position this view wants shown, or None to hide it. Base: Some(cursor) iff the view is focused with a visible cursor, else None. Read more
Source§

fn caret_size(&self) -> u8

The caret size this view wants while its cursor is shown, as a percentage of the character cell (1..=100). Base: CARET_INSERT (a block) when the cursor_ins state is set, else CARET_NORMAL (the normal caret). The event loop reads it along the same focused chain as cursor_request; Group overrides it to descend into its current child. Read more
Source§

fn find_mut(&mut self, id: ViewId) -> Option<&mut dyn View>

Resolve id to a descendant of this view (never self — the parent identifies a view by id). A leaf has no descendants, so the base returns None; a Group overrides to search its children and recurse; a Group-embedding view delegates to its inner group. This is the “tree-walk via Context” — the uniform way the event loop / a capture handler acts on a view it holds only by id (move a window’s bounds, flip the dragging flag, …).
Source§

fn remove_descendant(&mut self, id: ViewId, ctx: &mut Context<'_>) -> bool

Remove the descendant named by id from whichever group owns it. Returns true if it was found+removed. Distinct from find_mut because removal happens in the owner’s child Vec (a view cannot remove itself — it doesn’t know its owner) and must run the owning group’s reset_current. Base: false (a leaf owns nothing).
Source§

fn focus_descendant(&mut self, id: ViewId, ctx: &mut Context<'_>) -> bool

Focus (select) the descendant named by id within whichever group owns it — the tree-op behind a label focusing its linked control. Returns true if id was found in this subtree (selectable or not — finding it stops the walk). Distinct from find_mut because focusing happens in the owning group (a view cannot select itself within itself): the owning Group calls focus_child after applying the selectable gate. Base: false (a leaf owns nothing). Read more
Source§

fn has_focusable_leaf(&self) -> bool

Whether this view’s subtree contains a focusable leaf (visible, enabled, selectable). Base: whether THIS view is itself a focusable leaf; Group overrides to recurse into children; wrapper views delegate. Used by the hierarchical Tab traversal to skip selectable-but-empty subtrees.
Source§

fn focus_to_edge(&mut self, backward: bool, ctx: &mut Context<'_>) -> bool

Focus the first (Tab, backward = false) or last (Shift-Tab, backward = true) focusable leaf in this view’s subtree, establishing the full focus path down to it. Returns true if a focusable leaf was focused. Read more
Source§

fn reset_current(&mut self, ctx: &mut Context<'_>)

Establish this view’s INTERNAL currency — for a group-bearing view, set its current child to the first visible+selectable child. The insert-time currency cascade cannot run inside the context-less Group::insert, so exec_view calls this on a freshly-inserted modal BEFORE focusing it, so the modal’s first selectable child is current on open (otherwise the modal is keyboard-dead until a nav event — see the seam note in exec_view). Base: no-op (a leaf has no internal currency); Group overrides; Window/Dialog delegate.
Source§

fn settle_currency(&mut self, ctx: &mut Context<'_>)

Run any pending insert-time reset-current cascades in this subtree. Read more
Source§

fn set_visible_descendant( &mut self, id: ViewId, visible: bool, ctx: &mut Context<'_>, ) -> bool

Tree-op: set the visible flag of the descendant named by id from its OWNING group, running the owning group’s currency tail. Toggling visibility on a selectable view re-picks the owner’s current child, in both directions (show and hide). Returns true if id was found in this subtree. Read more
Source§

fn tile(&mut self, r: Rect)

Tree-op: lay this subtree’s tileable windows out in a grid (the tile command). Base: no-op (only Desktop lays out windows). r is the desktop-local layout rect. Mirrors select_window_num: the live loop drives the desktop by id through &mut dyn View.
Source§

fn cascade(&mut self, r: Rect)

Tree-op: lay this subtree’s tileable windows out cascaded (the cascade command). Base: no-op; Desktop overrides.
Source§

fn update_menu_commands(&mut self, cs: &CommandSet)

The menu command-graying broker hook. Defaulted no-op; menu views override to re-gray their menu tree against the program’s live disabled-command set (denylist — the argument is the set of commands currently disabled; an item grays iff its command is in it). The free fn menu::menu_view::update_menu_commands implements the re-gray walk. Read more
Source§

fn set_menu_current(&mut self, current: Option<usize>)

The menu-highlight write-back hook. Defaulted no-op; menu views (MenuBar / MenuBox) override to set their MenuViewState::current — the write-only display cache their draw reads to pick the selected colour. Read more
Source§

fn get_help_ctx(&self) -> HelpCtx

The effective help context for status-line switching. Returns HelpCtx::DRAGGING while the view is being dragged, otherwise the view’s own ViewState::help_ctx. Read more
Source§

fn descendant_global_bounds(&self, id: ViewId, acc: Point) -> Option<Rect>

Resolve descendant id to its absolute bounds, given acc = this view’s own absolute origin. Base returns None (a leaf owns no descendants); a Group overrides to walk its children accumulating origins, and a Group-embedding view delegates to its inner group. The THistory open path needs its linked input line’s bounds in the root/absolute frame, because exec_view root-inserts the modal and the modal frame hit-tests in absolute coords (the documented ROOT-INSERT + (0,0) caveat). Mirrors find_mut’s recursion but returns geometry, not a borrow.
Source§

fn set_indicator_value(&mut self, location: Point, modified: bool)

The editor→indicator status-push broker hook. Defaulted no-op; the editor’s status Indicator overrides it to store the new cursor location + modified flag. Driven by Deferred::IndicatorSetValue: the editor (a leaf) cannot reach its indicator sibling inline, so it requests this and the pump calls the method by id — virtual dispatch, not a downcast.
Source§

fn apply_page_sync(&mut self, idx: usize, ctx: &mut Context<'_>)

The tab-bar→page-stack switch broker hook. Defaulted no-op; PageStack overrides it to make page idx active. Driven by Deferred::PageStackSync: the pump reads the bound tab bar’s value and calls this method by id — virtual dispatch, not a downcast.
Source§

fn value(&self) -> Option<FieldValue>

This control’s current value as a FieldValue, or None for a view that carries no transferable data. Read more
Source§

fn set_value(&mut self, _v: FieldValue)

Load a typed FieldValue into this control. Read more
Source§

fn calc_bounds(&mut self, owner_size: Point, delta: Point) -> Rect

The new bounds after the owner resized to owner_size (delta = new - old). Computes the size limits via the overridable size_limits hook — so a widget override (e.g. a window’s minimum) participates — then delegates the grow math to ViewState::calc_bounds (the single source). Returns the bounds; it does not apply them (change_bounds does).
Source§

fn grabs_focus_on_click(&self) -> bool

Whether a mouse-down inside this view should auto-select (focus) it — the per-view opt-out for the group’s mouse-down auto-select (see Group::route_event). Default true (the common case); a Button overrides to return its grab-focus flag. A view returning false is not focused by a click but still receives the click (so it can act, e.g. press, without becoming the current view).
Source§

fn select_window_num(&mut self, num: i16, ctx: &mut Context<'_>) -> bool

Tree-op: ask this subtree to select the window numbered num. Returns whether one matched. Consistent with the find_mut / remove_descendant tree-op family: the live loop holds a subtree only by id (here, the desktop) and asks it to act. Default: no-op (false). Desktop overrides.
Source§

fn apply_scroll_sync( &mut self, _h: Option<i32>, _v: Option<i32>, _ctx: &mut Context<'_>, )

The shared scrollbar read-sync broker hook. Defaulted no-op; scroll-aware widgets override it to apply a freshly-read scrollbar delta to themselves. The pump passes the horizontal/vertical scrollbar values (None if that bar is absent or unresolved), each read via View::value. Overridden by the list viewers (delegate to list_viewer::apply_scroll), Scroller, the outline viewer, and the editor — every sibling-scrollbar read sync routes through this one method instead of a pump downcast. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Window

§

impl !Send for Window

§

impl !Sync for Window

§

impl !UnwindSafe for Window

§

impl Freeze for Window

§

impl Unpin for Window

§

impl UnsafeUnpin for Window

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
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
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, 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.