Skip to content

Commit

Permalink
delete deprecated functions
Browse files Browse the repository at this point in the history
  • Loading branch information
hymm committed Nov 22, 2023
1 parent 208ecb5 commit 629631f
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 309 deletions.
11 changes: 0 additions & 11 deletions crates/bevy_app/src/app.rs
Expand Up @@ -421,17 +421,6 @@ impl App {
self
}

/// Configures a system set in the default schedule, adding the set if it does not exist.
#[deprecated(since = "0.12.0", note = "Please use `configure_sets` instead.")]
#[track_caller]
pub fn configure_set(
&mut self,
schedule: impl ScheduleLabel,
set: impl IntoSystemSetConfigs,
) -> &mut Self {
self.configure_sets(schedule, set)
}

/// Configures a collection of system sets in the default schedule, adding any sets that do not exist.
#[track_caller]
pub fn configure_sets(
Expand Down
40 changes: 0 additions & 40 deletions crates/bevy_ecs/src/event.rs
Expand Up @@ -421,25 +421,11 @@ impl<'w, 's, E: Event> EventReader<'w, 's, E> {
self.reader.read(&self.events)
}

/// Iterates over the events this [`EventReader`] has not seen yet. This updates the
/// [`EventReader`]'s event counter, which means subsequent event reads will not include events
/// that happened before now.
#[deprecated = "use `.read()` instead."]
pub fn iter(&mut self) -> EventIterator<'_, E> {
self.reader.read(&self.events)
}

/// Like [`read`](Self::read), except also returning the [`EventId`] of the events.
pub fn read_with_id(&mut self) -> EventIteratorWithId<'_, E> {
self.reader.read_with_id(&self.events)
}

/// Like [`iter`](Self::iter), except also returning the [`EventId`] of the events.
#[deprecated = "use `.read_with_id() instead."]
pub fn iter_with_id(&mut self) -> EventIteratorWithId<'_, E> {
self.reader.read_with_id(&self.events)
}

/// Determines the number of events available to be read from this [`EventReader`] without consuming any.
pub fn len(&self) -> usize {
self.reader.len(&self.events)
Expand Down Expand Up @@ -583,23 +569,11 @@ impl<E: Event> ManualEventReader<E> {
self.read_with_id(events).without_id()
}

/// See [`EventReader::iter`]
#[deprecated = "use `.read()` instead."]
pub fn iter<'a>(&'a mut self, events: &'a Events<E>) -> EventIterator<'a, E> {
self.read_with_id(events).without_id()
}

/// See [`EventReader::read_with_id`]
pub fn read_with_id<'a>(&'a mut self, events: &'a Events<E>) -> EventIteratorWithId<'a, E> {
EventIteratorWithId::new(self, events)
}

/// See [`EventReader::iter_with_id`]
#[deprecated = "use `.read_with_id() instead."]
pub fn iter_with_id<'a>(&'a mut self, events: &'a Events<E>) -> EventIteratorWithId<'a, E> {
EventIteratorWithId::new(self, events)
}

/// See [`EventReader::len`]
pub fn len(&self, events: &Events<E>) -> usize {
// The number of events in this reader is the difference between the most recent event
Expand Down Expand Up @@ -636,13 +610,6 @@ pub struct EventIterator<'a, E: Event> {
iter: EventIteratorWithId<'a, E>,
}

/// An iterator that yields any unread events from an [`EventReader`] or [`ManualEventReader`].
///
/// This is a type alias for [`EventIterator`], which used to be called `ManualEventIterator`.
/// This type alias will be removed in the next release of bevy, so you should use [`EventIterator`] directly instead.
#[deprecated = "This type has been renamed to `EventIterator`."]
pub type ManualEventIterator<'a, E> = EventIterator<'a, E>;

impl<'a, E: Event> Iterator for EventIterator<'a, E> {
type Item = &'a E;
fn next(&mut self) -> Option<Self::Item> {
Expand Down Expand Up @@ -683,13 +650,6 @@ pub struct EventIteratorWithId<'a, E: Event> {
unread: usize,
}

/// An iterator that yields any unread events (and their IDs) from an [`EventReader`] or [`ManualEventReader`].
///
/// This is a type alias for [`EventIteratorWithId`], which used to be called `ManualEventIteratorWithId`.
/// This type alias will be removed in the next release of bevy, so you should use [`EventIteratorWithId`] directly instead.
#[deprecated = "This type has been renamed to `EventIteratorWithId`."]
pub type ManualEventIteratorWithId<'a, E> = EventIteratorWithId<'a, E>;

impl<'a, E: Event> EventIteratorWithId<'a, E> {
/// Creates a new iterator that yields any `events` that have not yet been seen by `reader`.
pub fn new(reader: &'a mut ManualEventReader<E>, events: &'a Events<E>) -> Self {
Expand Down
4 changes: 0 additions & 4 deletions crates/bevy_ecs/src/lib.rs
Expand Up @@ -28,10 +28,6 @@ pub mod prelude {
#[doc(hidden)]
#[cfg(feature = "bevy_reflect")]
pub use crate::reflect::{AppTypeRegistry, ReflectComponent, ReflectResource};
#[allow(deprecated)]
pub use crate::system::adapter::{
self as system_adapter, dbg, error, ignore, info, unwrap, warn,
};
#[doc(hidden)]
pub use crate::{
bundle::Bundle,
Expand Down
13 changes: 0 additions & 13 deletions crates/bevy_ecs/src/query/par_iter.rs
Expand Up @@ -156,19 +156,6 @@ impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> QueryParIter<'w, 's, Q, F> {
}
}

/// Runs `func` on each query result in parallel.
///
/// # Panics
/// If the [`ComputeTaskPool`] is not initialized. If using this from a query that is being
/// initialized and run from the ECS scheduler, this should never panic.
///
/// [`ComputeTaskPool`]: bevy_tasks::ComputeTaskPool
#[inline]
#[deprecated = "use `.for_each(...)` instead."]
pub fn for_each_mut<FN: Fn(QueryItem<'w, Q>) + Send + Sync + Clone>(self, func: FN) {
self.for_each(func);
}

#[cfg(all(not(target = "wasm32"), feature = "multi-threaded"))]
fn get_batch_size(&self, thread_count: usize) -> usize {
if self.batching_strategy.batch_size_limits.is_empty() {
Expand Down
14 changes: 0 additions & 14 deletions crates/bevy_ecs/src/removal_detection.rs
Expand Up @@ -208,14 +208,6 @@ impl<'w, 's, T: Component> RemovedComponents<'w, 's, T> {
.map(RemovedComponentEntity::into)
}

/// Iterates over the events this [`RemovedComponents`] has not seen yet. This updates the
/// [`RemovedComponents`]'s event counter, which means subsequent event reads will not include events
/// that happened before now.
#[deprecated = "use `.read()` instead."]
pub fn iter(&mut self) -> RemovedIter<'_> {
self.read()
}

/// Like [`read`](Self::read), except also returning the [`EventId`] of the events.
pub fn read_with_id(&mut self) -> RemovedIterWithId<'_> {
self.reader_mut_with_events()
Expand All @@ -225,12 +217,6 @@ impl<'w, 's, T: Component> RemovedComponents<'w, 's, T> {
.map(map_id_events)
}

/// Like [`iter`](Self::iter), except also returning the [`EventId`] of the events.
#[deprecated = "use `.read_with_id()` instead."]
pub fn iter_with_id(&mut self) -> RemovedIterWithId<'_> {
self.read_with_id()
}

/// Determines the number of removal events available to be read from this [`RemovedComponents`] without consuming any.
pub fn len(&self) -> usize {
self.events()
Expand Down
7 changes: 0 additions & 7 deletions crates/bevy_ecs/src/schedule/schedule.rs
Expand Up @@ -232,13 +232,6 @@ impl Schedule {
self
}

/// Configures a system set in this schedule, adding it if it does not exist.
#[deprecated(since = "0.12.0", note = "Please use `configure_sets` instead.")]
#[track_caller]
pub fn configure_set(&mut self, set: impl IntoSystemSetConfigs) -> &mut Self {
self.configure_sets(set)
}

/// Configures a collection of system sets in this schedule, adding them if they does not exist.
#[track_caller]
pub fn configure_sets(&mut self, sets: impl IntoSystemSetConfigs) -> &mut Self {
Expand Down
220 changes: 0 additions & 220 deletions crates/bevy_ecs/src/system/mod.rs
Expand Up @@ -232,226 +232,6 @@ impl<T: System> IntoSystem<T::In, T::Out, ()> for T {
/// ```
pub struct In<In>(pub In);

/// A collection of common adapters for [piping](crate::system::PipeSystem) the result of a system.
#[deprecated = "this form of system adapter has been deprecated in favor of `system.map(...)`"]
pub mod adapter {
use crate::system::In;
use bevy_utils::tracing;
use std::fmt::Debug;

/// Converts a regular function into a system adapter.
///
/// # Examples
/// ```
/// use bevy_ecs::prelude::*;
///
/// fn return1() -> u64 { 1 }
///
/// return1
/// .pipe(system_adapter::new(u32::try_from))
/// .pipe(system_adapter::unwrap)
/// .pipe(print);
///
/// fn print(In(x): In<impl std::fmt::Debug>) {
/// println!("{x:?}");
/// }
/// ```
#[deprecated = "use `.map(...)` instead"]
pub fn new<T, U>(mut f: impl FnMut(T) -> U) -> impl FnMut(In<T>) -> U {
move |In(x)| f(x)
}

/// System adapter that unwraps the `Ok` variant of a [`Result`].
/// This is useful for fallible systems that should panic in the case of an error.
///
/// There is no equivalent adapter for [`Option`]. Instead, it's best to provide
/// an error message and convert to a `Result` using `ok_or{_else}`.
///
/// # Examples
///
/// Panicking on error
///
/// ```
/// use bevy_ecs::prelude::*;
///
/// // Building a new schedule/app...
/// let mut sched = Schedule::default();
/// sched.add_systems(
/// // Panic if the load system returns an error.
/// load_save_system.pipe(system_adapter::unwrap)
/// )
/// // ...
/// # ;
/// # let mut world = World::new();
/// # sched.run(&mut world);
///
/// // A system which may fail irreparably.
/// fn load_save_system() -> Result<(), std::io::Error> {
/// let save_file = open_file("my_save.json")?;
/// dbg!(save_file);
/// Ok(())
/// }
/// # fn open_file(name: &str) -> Result<&'static str, std::io::Error>
/// # { Ok("hello world") }
/// ```
#[deprecated = "use `.map(Result::unwrap)` instead"]
pub fn unwrap<T, E: Debug>(In(res): In<Result<T, E>>) -> T {
res.unwrap()
}

/// System adapter that utilizes the [`bevy_utils::tracing::info!`] macro to print system information.
///
/// # Examples
///
/// ```
/// use bevy_ecs::prelude::*;
///
/// // Building a new schedule/app...
/// let mut sched = Schedule::default();
/// sched.add_systems(
/// // Prints system information.
/// data_pipe_system.pipe(system_adapter::info)
/// )
/// // ...
/// # ;
/// # let mut world = World::new();
/// # sched.run(&mut world);
///
/// // A system that returns a String output.
/// fn data_pipe_system() -> String {
/// "42".to_string()
/// }
/// ```
#[deprecated = "use `.map(bevy_utils::info)` instead"]
pub fn info<T: Debug>(In(data): In<T>) {
tracing::info!("{:?}", data);
}

/// System adapter that utilizes the [`bevy_utils::tracing::debug!`] macro to print the output of a system.
///
/// # Examples
///
/// ```
/// use bevy_ecs::prelude::*;
///
/// // Building a new schedule/app...
/// let mut sched = Schedule::default();
/// sched.add_systems(
/// // Prints debug data from system.
/// parse_message_system.pipe(system_adapter::dbg)
/// )
/// // ...
/// # ;
/// # let mut world = World::new();
/// # sched.run(&mut world);
///
/// // A system that returns a Result<usize, String> output.
/// fn parse_message_system() -> Result<usize, std::num::ParseIntError> {
/// Ok("42".parse()?)
/// }
/// ```
#[deprecated = "use `.map(bevy_utils::dbg)` instead"]
pub fn dbg<T: Debug>(In(data): In<T>) {
tracing::debug!("{:?}", data);
}

/// System adapter that utilizes the [`bevy_utils::tracing::warn!`] macro to print the output of a system.
///
/// # Examples
///
/// ```
/// use bevy_ecs::prelude::*;
///
/// // Building a new schedule/app...
/// # let mut sched = Schedule::default();
/// sched.add_systems(
/// // Prints system warning if system returns an error.
/// warning_pipe_system.pipe(system_adapter::warn)
/// )
/// // ...
/// # ;
/// # let mut world = World::new();
/// # sched.run(&mut world);
///
/// // A system that returns a Result<(), String> output.
/// fn warning_pipe_system() -> Result<(), String> {
/// Err("Got to rusty?".to_string())
/// }
/// ```
#[deprecated = "use `.map(bevy_utils::warn)` instead"]
pub fn warn<E: Debug>(In(res): In<Result<(), E>>) {
if let Err(warn) = res {
tracing::warn!("{:?}", warn);
}
}

/// System adapter that utilizes the [`bevy_utils::tracing::error!`] macro to print the output of a system.
///
/// # Examples
///
/// ```
/// use bevy_ecs::prelude::*;
/// // Building a new schedule/app...
/// let mut sched = Schedule::default();
/// sched.add_systems(
/// // Prints system error if system fails.
/// parse_error_message_system.pipe(system_adapter::error)
/// )
/// // ...
/// # ;
/// # let mut world = World::new();
/// # sched.run(&mut world);
///
/// // A system that returns a Result<())> output.
/// fn parse_error_message_system() -> Result<(), String> {
/// Err("Some error".to_owned())
/// }
/// ```
#[deprecated = "use `.map(bevy_utils::error)` instead"]
pub fn error<E: Debug>(In(res): In<Result<(), E>>) {
if let Err(error) = res {
tracing::error!("{:?}", error);
}
}

/// System adapter that ignores the output of the previous system in a pipe.
/// This is useful for fallible systems that should simply return early in case of an `Err`/`None`.
///
/// # Examples
///
/// Returning early
///
/// ```
/// use bevy_ecs::prelude::*;
///
/// // Marker component for an enemy entity.
/// #[derive(Component)]
/// struct Monster;
///
/// // Building a new schedule/app...
/// # let mut sched = Schedule::default(); sched
/// .add_systems(
/// // If the system fails, just move on and try again next frame.
/// fallible_system.pipe(system_adapter::ignore)
/// )
/// // ...
/// # ;
/// # let mut world = World::new();
/// # sched.run(&mut world);
///
/// // A system which may return early. It's more convenient to use the `?` operator for this.
/// fn fallible_system(
/// q: Query<Entity, With<Monster>>
/// ) -> Option<()> {
/// let monster_id = q.iter().next()?;
/// println!("Monster entity is {monster_id:?}");
/// Some(())
/// }
/// ```
#[deprecated = "use `.map(std::mem::drop)` instead"]
pub fn ignore<T>(In(_): In<T>) {}
}

/// Ensure that a given function is a [system](System).
///
/// This should be used when writing doc examples,
Expand Down

0 comments on commit 629631f

Please sign in to comment.