Skip to content

Commit

Permalink
fix readme links
Browse files Browse the repository at this point in the history
RobWalt committed Nov 1, 2024

Verified

This commit was signed with the committer’s verified signature. The key has expired.
RobWalt RobWalt
1 parent 5cc79e5 commit 6f555b9
Showing 2 changed files with 20 additions and 20 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -121,7 +121,7 @@ fn show_tooltips(
```

Alternatively, if you expect to only have component implementing the trait for each entity,
you can use the filter [`One`]. This has significantly better performance than iterating
you can use the filter [`One`](https://docs.rs/bevy-trait-query/latest/bevy_trait_query/one/struct.One.html). This has significantly better performance than iterating
over all trait impls.

```rust
@@ -139,10 +139,10 @@ fn show_tooltips(

Trait queries support basic change detection filtration.

- queries requesting shared access yield [`ReadTraits`] which is similar to
[`bevy_ecs::change_detection::Ref`]
- queries requesting exclusive access yield [`WriteTraits`] which is similar to
[`bevy_ecs::change_detection::Mut`]
- queries requesting shared access yield [`crate::all::ReadTraits`] which is similar to
[`Ref`](bevy_ecs::change_detection::Ref)
- queries requesting exclusive access yield [`crate::all::WriteTraits`] which is similar to
[`Mut`](bevy_ecs::change_detection::Mut)

To get all the components that implement the target trait, and have also changed in some way
since the last tick, you can:
@@ -162,12 +162,12 @@ fn show_tooltips(
}
```

Similar to [`iter_changed`](ReadTraits::iter_changed), we have [`iter_added`](ReadTraits::iter_added)
Similar to [`iter_changed`](https://docs.rs/bevy-trait-query/latest/bevy_trait_query/all/struct.ReadTraits.html), we have [`iter_added`](https://docs.rs/bevy-trait-query/latest/bevy_trait_query/all/struct.ReadTraits.html)
to detect entities which have had a trait-implementing component added since the last tick.

If you know you have only one component that implements the target trait,
you can use `OneAdded` or `OneChanged` which behave more like the typical
`bevy` `Added/Changed` filters:
you can use [`OneAdded`](https://docs.rs/bevy-trait-query/latest/bevy_trait_query/one/struct.OneAdded.html) or [`OneChanged`](https://docs.rs/bevy-trait-query/latest/bevy_trait_query/one/struct.OneChanged.html) which behave more like the typical
`bevy` [`Added`](bevy::prelude::Added)/[`Changed`](bevy::prelude::Changed) filters:
```rust
fn show_tooltips(
tooltips_query: Query<One<&dyn Tooltip>, OneChanged<dyn Tooltip>>
@@ -179,13 +179,13 @@ fn show_tooltips(
}
}
```
Note in the above example how `OneChanged` does *not* take a reference to the trait object!
Note in the above example how [`OneChanged`](https://docs.rs/bevy-trait-query/latest/bevy_trait_query/one/struct.OneChanged.html) does *not* take a reference to the trait object!

### Performance

The performance of trait queries is quite competitive. Here are some benchmarks for simple cases:

| | Concrete type | `One<dyn Trait>` | `All<dyn Trait>` |
| | Concrete type | [`One<dyn Trait>`](https://docs.rs/bevy-trait-query/latest/bevy_trait_query/one/struct.One.html) | [`All<dyn Trait>`](https://docs.rs/bevy-trait-query/latest/bevy_trait_query/all/struct.All.html) |
|-------------------|----------------|---------------------|-------------------|
| 1 match | 8.395 µs | 28.174 µs | 81.027 µs |
| 2 matches | 8.473 µs | - | 106.47 µs |
20 changes: 10 additions & 10 deletions bevy-trait-query/src/lib.rs
Original file line number Diff line number Diff line change
@@ -161,7 +161,7 @@
//! ```
//!
//! Alternatively, if you expect to only have component implementing the trait for each entity,
//! you can use the filter [`One`]. This has significantly better performance than iterating
//! you can use the filter [`One`](crate::one::One). This has significantly better performance than iterating
//! over all trait impls.
//!
//! ```
@@ -188,10 +188,10 @@
//!
//! Trait queries support basic change detection filtration.
//!
//! - queries requesting shared access yield [`ReadTraits`] which is similar to
//! [`bevy_ecs::change_detection::Ref`]
//! - queries requesting exclusive access yield [`WriteTraits`] which is similar to
//! [`bevy_ecs::change_detection::Mut`]
//! - queries requesting shared access yield [`crate::all::ReadTraits`] which is similar to
//! [`Ref`](bevy_ecs::change_detection::Ref)
//! - queries requesting exclusive access yield [`crate::all::WriteTraits`] which is similar to
//! [`Mut`](bevy_ecs::change_detection::Mut)
//!
//! To get all the components that implement the target trait, and have also changed in some way
//! since the last tick, you can:
@@ -219,12 +219,12 @@
//! }
//! ```
//!
//! Similar to [`iter_changed`](ReadTraits::iter_changed), we have [`iter_added`](ReadTraits::iter_added)
//! Similar to [`iter_changed`](crate::all::ReadTraits), we have [`iter_added`](crate::all::ReadTraits)
//! to detect entities which have had a trait-implementing component added since the last tick.
//!
//! If you know you have only one component that implements the target trait,
//! you can use `OneAdded` or `OneChanged` which behave more like the typical
//! `bevy` `Added/Changed` filters:
//! you can use [`OneAdded`](crate::one::OneAdded) or [`OneChanged`](crate::one::OneChanged) which behave more like the typical
//! `bevy` [`Added`](bevy::prelude::Added)/[`Changed`](bevy::prelude::Changed) filters:
//! ```no_run
//! # use bevy::prelude::*;
//! # use bevy_trait_query::*;
@@ -244,13 +244,13 @@
//! }
//! }
//! ```
//! Note in the above example how `OneChanged` does *not* take a reference to the trait object!
//! Note in the above example how [`OneChanged`](crate::one::OneChanged) does *not* take a reference to the trait object!
//!
//! # Performance
//!
//! The performance of trait queries is quite competitive. Here are some benchmarks for simple cases:
//!
//! | | Concrete type | `One<dyn Trait>` | `All<dyn Trait>` |
//! | | Concrete type | [`One<dyn Trait>`](crate::one::One) | [`All<dyn Trait>`](crate::all::All) |
//! |-------------------|----------------|---------------------|-------------------|
//! | 1 match | 8.395 µs | 28.174 µs | 81.027 µs |
//! | 2 matches | 8.473 µs | - | 106.47 µs |

0 comments on commit 6f555b9

Please sign in to comment.