# Selector

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/styling/struct-selector/

**struct** · [`ferroui-base`](/docs/0.5.0/api/ferroui-base/) · v0.5.0

```rust
struct Selector
```

A selector in a [`Style`](/docs/0.5.0/api/ferroui-base/styling/struct-style/).

Selectors are built with the functions of `Selectors`
and the chaining methods of this type. A selector is a shared, immutable
description: cloning the handle is cheap.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/selector.rs#L74)

## Members

- [`target_type`](#function-target_type)
- [`match_`](#function-match_)
- [`to_string_with_owner`](#function-to_string_with_owner)
- [`child`](#function-child)
- [`class`](#function-class)
- [`descendant`](#function-descendant)
- [`is`](#function-is)
- [`is_type_info`](#function-is_type_info)
- [`name`](#function-name)
- [`nesting`](#function-nesting)
- [`not`](#function-not)
- [`not_with`](#function-not_with)
- [`nth_child`](#function-nth_child)
- [`nth_last_child`](#function-nth_last_child)
- [`of_type`](#function-of_type)
- [`of_type_info`](#function-of_type_info)
- [`property_equals`](#function-property_equals)
- [`property_equals_untyped`](#function-property_equals_untyped)
- [`template`](#function-template)

<a id="function-target_type"></a>

### target_type

```rust
fn target_type(self: &Self) -> Option<&'static TypeInfo>
```

The target type of the selector, if available.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/selector.rs#L105)

<a id="function-match_"></a>

### match_

```rust
fn match_(self: &Self, control: &StyledElement, parent: Option<&StyleBase>, subscribe: bool) -> SelectorMatch
```

Tries to match the selector with a control.

`parent` is the parent style, if the style containing the selector is
a nested style. With `subscribe`, a match whose state can change over
time carries an activator that tracks it; without, the match is only
evaluated for the current state.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/selector.rs#L171)

<a id="function-to_string_with_owner"></a>

### to_string_with_owner

```rust
fn to_string_with_owner(self: &Self, owner: Option<&Style>) -> String
```

Gets a string representing the selector, with the nesting separator
(`^`) replaced with the parent selector.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/selector.rs#L199)

<a id="function-child"></a>

### child

```rust
fn child(self: Self) -> Selector
```

Returns a selector which matches this selector's child.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/selectors.rs#L145)

<a id="function-class"></a>

### class

```rust
fn class(self: Self, name: &str) -> Selector
```

Returns a selector which additionally matches a control's style class.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/selectors.rs#L150)

<a id="function-descendant"></a>

### descendant

```rust
fn descendant(self: Self) -> Selector
```

Returns a selector which matches a descendant of this selector.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/selectors.rs#L155)

<a id="function-is"></a>

### is

```rust
fn is<T: ObjectType + Upcast<StyledElement>>(self: Self) -> Selector
```

Returns a selector which additionally matches class `T` or a class
derived from it.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/selectors.rs#L161)

<a id="function-is_type_info"></a>

### is_type_info

```rust
fn is_type_info(self: Self, type_: &'static TypeInfo) -> Selector
```

Returns a selector which additionally matches a type or a derived
type.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/selectors.rs#L167)

<a id="function-name"></a>

### name

```rust
fn name(self: Self, name: &str) -> Selector
```

Returns a selector which additionally matches a control's name.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/selectors.rs#L172)

<a id="function-nesting"></a>

### nesting

```rust
fn nesting(self: Self) -> Selector
```

Returns the nesting selector.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/selectors.rs#L177)

<a id="function-not"></a>

### not

```rust
fn not(self: Self, argument: Selector) -> Selector
```

Returns a selector which additionally inverts the results of
`argument`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/selectors.rs#L183)

<a id="function-not_with"></a>

### not_with

```rust
fn not_with(self: Self, argument: impl FnOnce(Option<Selector>) -> Selector) -> Selector
```

Returns a selector which additionally inverts the results of the
selector built by `argument`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/selectors.rs#L189)

<a id="function-nth_child"></a>

### nth_child

```rust
fn nth_child(self: Self, step: i32, offset: i32) -> Selector
```

Returns a selector which additionally matches elements based on their
position among a group of siblings.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/selectors.rs#L195)

<a id="function-nth_last_child"></a>

### nth_last_child

```rust
fn nth_last_child(self: Self, step: i32, offset: i32) -> Selector
```

Returns a selector which additionally matches elements based on their
position among a group of siblings, counting from the end.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/selectors.rs#L201)

<a id="function-of_type"></a>

### of_type

```rust
fn of_type<T: ObjectType + Upcast<StyledElement>>(self: Self) -> Selector
```

Returns a selector which additionally matches class `T` exactly.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/selectors.rs#L206)

<a id="function-of_type_info"></a>

### of_type_info

```rust
fn of_type_info(self: Self, type_: &'static TypeInfo) -> Selector
```

Returns a selector which additionally matches a type.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/selectors.rs#L211)

<a id="function-property_equals"></a>

### property_equals

```rust
fn property_equals<T: PropertyValue>(self: Self, property: &'static StyledProperty<T>, value: T) -> Selector
```

Returns a selector which additionally matches a control with the
specified property value.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/selectors.rs#L217)

<a id="function-property_equals_untyped"></a>

### property_equals_untyped

```rust
fn property_equals_untyped(self: Self, property: &'static FerroProperty, value: BoxedValue) -> Selector
```

Returns a selector which additionally matches a control with the
specified property value. `value` must hold exactly the property's
value type.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/selectors.rs#L224)

<a id="function-template"></a>

### template

```rust
fn template(self: Self) -> Selector
```

Returns a selector which enters a lookless control's template.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/selectors.rs#L229)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`PropertyValue`](/docs/0.5.0/api/ferroui-base/trait-propertyvalue/)
- [`AnyValue`](/docs/0.5.0/api/ferroui-base/trait-anyvalue/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- `ToString`
- `ErasedDestructor`
- `IntoEither`
- `Clone`
- `PartialEq`
- `Display`
- `Debug`
- [`MarkupTyped`](/docs/0.5.0/api/ferroui-base/metadata/trait-markuptyped/)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
