# Trait glib::object::Downcast [−] [src]

    pub trait Downcast<T> {
        fn can_downcast(&self) -> bool;
        fn downcast(self) -> Result<T, Self>
        where
            Self: Sized;
        unsafe fn downcast_unchecked(self) -> T;
    }

Downcasts support.

## Required Methods

### `fn can_downcast(&self) -> bool`

Checks if it's possible to downcast to `T`.

Returns `true` if the instance implements `T` and `false` otherwise.

### `fn downcast(self) -> Result<T, Self> where
Self: Sized,`

Tries to downcast to `T`.

Returns `Ok(T)` if the instance implements `T` and `Err(Self)` otherwise.

### `unsafe fn downcast_unchecked(self) -> T`

Downcasts to `T` unconditionally.

Panics if compiled with `debug_assertions` and the instance doesn't implement `T`.

## Implementors

- `impl<Super: IsA<Super>, Sub: IsA<Super>> Downcast<Sub> for Super`

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
↑
  Move up in search results
↓
  Move down in search results
↹
  Switch tab
⏎
  Go to active search result
+ / -
  Collapse/expand all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)