# Struct glib::variant::Variant [−] [src]

    pub struct Variant(_);

A generic immutable value capable of carrying various types.

See the module documentation for more details.

## Methods

### `impl Variant`
[src]

#### `pub fn type_(&self) -> &VariantTy`
[src]

Returns the type of the value.

#### `pub fn is<T: StaticVariantType>(&self) -> bool`
[src]

Returns `true` if the type of the value corresponds to `T`.

#### `pub fn get<T: FromVariant>(&self) -> Option<T>`
[src]

Tries to extract a value of type `T`.

Returns `Some` if `T` matches the variant's type.

#### `pub fn get_str(&self) -> Option<&str>`
[src]

Tries to extract a `&str`.

Returns `Some` if the variant has a string type (`s`, `o` or `g` type strings).

## Trait Implementations

### `impl Clone for Variant`
[src]

#### `fn clone(&self) -> Variant`
[src]

Returns a copy of the value. Read more

#### `fn clone_from(&mut self, source: &Self)`
1.0.0
[src]

Performs copy-assignment from `source`. Read more

### `impl StaticType for Variant`
[src]

#### `fn static_type() -> Type`
[src]

Returns the type identifier of `Self`.

### `impl Send for Variant`
[src]

### `impl Sync for Variant`
[src]

### `impl Debug for Variant`
[src]

#### `fn fmt(&self, f: &mut Formatter) -> Result`
[src]

Formats the value using the given formatter. Read more

### `impl Display for Variant`
[src]

#### `fn fmt(&self, f: &mut Formatter) -> Result`
[src]

Formats the value using the given formatter. Read more

### `impl PartialEq for Variant`
[src]

#### `fn eq(&self, other: &Self) -> bool`
[src]

This method tests for `self` and `other` values to be equal, and is used by `==`. Read more

#### `fn ne(&self, other: &Rhs) -> bool`
1.0.0
[src]

This method tests for `!=`.

### `impl Eq for Variant`
[src]

### `impl Hash for Variant`
[src]

#### `fn hash<H: Hasher>(&self, state: &mut H)`
[src]

Feeds this value into the given [`Hasher`]. Read more

#### `fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,`
1.3.0
[src]

Feeds a slice of this type into the given [`Hasher`]. Read more

### `impl<T: ToVariant> From<T> for Variant`
[src]

#### `fn from(value: T) -> Variant`
[src]

Performs the conversion.

# 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`)