fix doc tests for errors
This commit is contained in:
parent
38a97105a4
commit
8956adcc5b
@ -1132,6 +1132,20 @@ pub enum ConstructedEntityDoesNotExistError {
|
|||||||
WasNotConstructed(#[from] EntityNotConstructedError),
|
WasNotConstructed(#[from] EntityNotConstructedError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ConstructedEntityDoesNotExistError {
|
||||||
|
/// The entity that did not exist or was not constructed.
|
||||||
|
pub fn entity(&self) -> Entity {
|
||||||
|
match self {
|
||||||
|
ConstructedEntityDoesNotExistError::DidNotExist(entity_does_not_exist_error) => {
|
||||||
|
entity_does_not_exist_error.entity
|
||||||
|
}
|
||||||
|
ConstructedEntityDoesNotExistError::WasNotConstructed(entity_not_constructed_error) => {
|
||||||
|
entity_not_constructed_error.entity
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
struct EntityMeta {
|
struct EntityMeta {
|
||||||
/// The current [`EntityGeneration`] of the [`EntityRow`].
|
/// The current [`EntityGeneration`] of the [`EntityRow`].
|
||||||
|
|||||||
@ -885,7 +885,7 @@ impl<D: QueryData, F: QueryFilter> QueryState<D, F> {
|
|||||||
///
|
///
|
||||||
/// let wrong_entity = Entity::from_raw_u32(365).unwrap();
|
/// let wrong_entity = Entity::from_raw_u32(365).unwrap();
|
||||||
///
|
///
|
||||||
/// assert_eq!(match query_state.get_many(&mut world, [wrong_entity]).unwrap_err() {QueryEntityError::EntityDoesNotExist(error) => error.entity, _ => panic!()}, wrong_entity);
|
/// assert_eq!(match query_state.get_many(&mut world, [wrong_entity]).unwrap_err() {QueryEntityError::EntityDoesNotExist(error) => error.entity(), _ => panic!()}, wrong_entity);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_many<'w, const N: usize>(
|
pub fn get_many<'w, const N: usize>(
|
||||||
@ -923,7 +923,7 @@ impl<D: QueryData, F: QueryFilter> QueryState<D, F> {
|
|||||||
///
|
///
|
||||||
/// let wrong_entity = Entity::from_raw_u32(365).unwrap();
|
/// let wrong_entity = Entity::from_raw_u32(365).unwrap();
|
||||||
///
|
///
|
||||||
/// assert_eq!(match query_state.get_many_unique(&mut world, UniqueEntityArray::from([wrong_entity])).unwrap_err() {QueryEntityError::EntityDoesNotExist(error) => error.entity, _ => panic!()}, wrong_entity);
|
/// assert_eq!(match query_state.get_many_unique(&mut world, UniqueEntityArray::from([wrong_entity])).unwrap_err() {QueryEntityError::EntityDoesNotExist(error) => error.entity(), _ => panic!()}, wrong_entity);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_many_unique<'w, const N: usize>(
|
pub fn get_many_unique<'w, const N: usize>(
|
||||||
@ -980,7 +980,7 @@ impl<D: QueryData, F: QueryFilter> QueryState<D, F> {
|
|||||||
/// let wrong_entity = Entity::from_raw_u32(57).unwrap();
|
/// let wrong_entity = Entity::from_raw_u32(57).unwrap();
|
||||||
/// let invalid_entity = world.spawn_empty().id();
|
/// let invalid_entity = world.spawn_empty().id();
|
||||||
///
|
///
|
||||||
/// assert_eq!(match query_state.get_many(&mut world, [wrong_entity]).unwrap_err() {QueryEntityError::EntityDoesNotExist(error) => error.entity, _ => panic!()}, wrong_entity);
|
/// assert_eq!(match query_state.get_many(&mut world, [wrong_entity]).unwrap_err() {QueryEntityError::EntityDoesNotExist(error) => error.entity(), _ => panic!()}, wrong_entity);
|
||||||
/// assert_eq!(match query_state.get_many_mut(&mut world, [invalid_entity]).unwrap_err() {QueryEntityError::QueryDoesNotMatch(entity, _) => entity, _ => panic!()}, invalid_entity);
|
/// assert_eq!(match query_state.get_many_mut(&mut world, [invalid_entity]).unwrap_err() {QueryEntityError::QueryDoesNotMatch(entity, _) => entity, _ => panic!()}, invalid_entity);
|
||||||
/// assert_eq!(query_state.get_many_mut(&mut world, [entities[0], entities[0]]).unwrap_err(), QueryEntityError::AliasedMutability(entities[0]));
|
/// assert_eq!(query_state.get_many_mut(&mut world, [entities[0], entities[0]]).unwrap_err(), QueryEntityError::AliasedMutability(entities[0]));
|
||||||
/// ```
|
/// ```
|
||||||
@ -1026,7 +1026,7 @@ impl<D: QueryData, F: QueryFilter> QueryState<D, F> {
|
|||||||
/// let wrong_entity = Entity::from_raw_u32(57).unwrap();
|
/// let wrong_entity = Entity::from_raw_u32(57).unwrap();
|
||||||
/// let invalid_entity = world.spawn_empty().id();
|
/// let invalid_entity = world.spawn_empty().id();
|
||||||
///
|
///
|
||||||
/// assert_eq!(match query_state.get_many_unique(&mut world, UniqueEntityArray::from([wrong_entity])).unwrap_err() {QueryEntityError::EntityDoesNotExist(error) => error.entity, _ => panic!()}, wrong_entity);
|
/// assert_eq!(match query_state.get_many_unique(&mut world, UniqueEntityArray::from([wrong_entity])).unwrap_err() {QueryEntityError::EntityDoesNotExist(error) => error.entity(), _ => panic!()}, wrong_entity);
|
||||||
/// assert_eq!(match query_state.get_many_unique_mut(&mut world, UniqueEntityArray::from([invalid_entity])).unwrap_err() {QueryEntityError::QueryDoesNotMatch(entity, _) => entity, _ => panic!()}, invalid_entity);
|
/// assert_eq!(match query_state.get_many_unique_mut(&mut world, UniqueEntityArray::from([invalid_entity])).unwrap_err() {QueryEntityError::QueryDoesNotMatch(entity, _) => entity, _ => panic!()}, invalid_entity);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|||||||
@ -1419,7 +1419,7 @@ impl<'w, 's, D: QueryData, F: QueryFilter> Query<'w, 's, D, F> {
|
|||||||
///
|
///
|
||||||
/// assert_eq!(
|
/// assert_eq!(
|
||||||
/// match query.get_many([wrong_entity]).unwrap_err() {
|
/// match query.get_many([wrong_entity]).unwrap_err() {
|
||||||
/// QueryEntityError::EntityDoesNotExist(error) => error.entity,
|
/// QueryEntityError::EntityDoesNotExist(error) => error.entity(),
|
||||||
/// _ => panic!(),
|
/// _ => panic!(),
|
||||||
/// },
|
/// },
|
||||||
/// wrong_entity
|
/// wrong_entity
|
||||||
@ -1470,7 +1470,7 @@ impl<'w, 's, D: QueryData, F: QueryFilter> Query<'w, 's, D, F> {
|
|||||||
///
|
///
|
||||||
/// assert_eq!(
|
/// assert_eq!(
|
||||||
/// match query.get_many_unique(UniqueEntityArray::from([wrong_entity])).unwrap_err() {
|
/// match query.get_many_unique(UniqueEntityArray::from([wrong_entity])).unwrap_err() {
|
||||||
/// QueryEntityError::EntityDoesNotExist(error) => error.entity,
|
/// QueryEntityError::EntityDoesNotExist(error) => error.entity(),
|
||||||
/// _ => panic!(),
|
/// _ => panic!(),
|
||||||
/// },
|
/// },
|
||||||
/// wrong_entity
|
/// wrong_entity
|
||||||
@ -1629,7 +1629,7 @@ impl<'w, 's, D: QueryData, F: QueryFilter> Query<'w, 's, D, F> {
|
|||||||
/// .get_many_mut([wrong_entity])
|
/// .get_many_mut([wrong_entity])
|
||||||
/// .unwrap_err()
|
/// .unwrap_err()
|
||||||
/// {
|
/// {
|
||||||
/// QueryEntityError::EntityDoesNotExist(error) => error.entity,
|
/// QueryEntityError::EntityDoesNotExist(error) => error.entity(),
|
||||||
/// _ => panic!(),
|
/// _ => panic!(),
|
||||||
/// },
|
/// },
|
||||||
/// wrong_entity
|
/// wrong_entity
|
||||||
@ -1703,7 +1703,7 @@ impl<'w, 's, D: QueryData, F: QueryFilter> Query<'w, 's, D, F> {
|
|||||||
/// .get_many_unique_mut(UniqueEntityArray::from([wrong_entity]))
|
/// .get_many_unique_mut(UniqueEntityArray::from([wrong_entity]))
|
||||||
/// .unwrap_err()
|
/// .unwrap_err()
|
||||||
/// {
|
/// {
|
||||||
/// QueryEntityError::EntityDoesNotExist(error) => error.entity,
|
/// QueryEntityError::EntityDoesNotExist(error) => error.entity(),
|
||||||
/// _ => panic!(),
|
/// _ => panic!(),
|
||||||
/// },
|
/// },
|
||||||
/// wrong_entity
|
/// wrong_entity
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user