Skip to content

Commit

Permalink
Remove *_arc methods (serenity-rs#2654)
Browse files Browse the repository at this point in the history
These are unnecessary. Accepting `impl Into<Arc<T>>` allows passing either `T` or `Arc<T>`.
  • Loading branch information
GnomedDev authored and mkrasnitski committed Dec 8, 2024
1 parent bfa98b3 commit 062972b
Showing 1 changed file with 7 additions and 33 deletions.
40 changes: 7 additions & 33 deletions src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,31 +204,12 @@ impl ClientBuilder {

/// Sets the voice gateway handler to be used. It will receive voice events sent over the
/// gateway and then consider - based on its settings - whether to dispatch a command.
///
/// *Info*: If a reference to the voice_manager is required for manual dispatch, use the
/// [`Self::voice_manager_arc`]-method instead.
#[cfg(feature = "voice")]
pub fn voice_manager<V>(mut self, voice_manager: V) -> Self
pub fn voice_manager<V>(mut self, voice_manager: impl Into<Arc<V>>) -> Self
where
V: VoiceGatewayManager + 'static,
{
self.voice_manager = Some(Arc::new(voice_manager));

self
}

/// This method allows to pass an [`Arc`]'ed `voice_manager` - this step is done for you in the
/// [`voice_manager`]-method, if you don't need the extra control. You can provide a clone and
/// keep the original to manually dispatch.
///
/// [`voice_manager`]: Self::voice_manager
#[cfg(feature = "voice")]
pub fn voice_manager_arc(
mut self,
voice_manager: Arc<dyn VoiceGatewayManager + 'static>,
) -> Self {
self.voice_manager = Some(voice_manager);

self.voice_manager = Some(voice_manager.into());
self
}

Expand Down Expand Up @@ -270,18 +251,11 @@ impl ClientBuilder {
}

/// Adds an event handler with multiple methods for each possible event.
pub fn event_handler<H: EventHandler + 'static>(mut self, event_handler: H) -> Self {
self.event_handlers.push(Arc::new(event_handler));

self
}

/// Adds an event handler with multiple methods for each possible event. Passed by Arc.
pub fn event_handler_arc<H: EventHandler + 'static>(
mut self,
event_handler_arc: Arc<H>,
) -> Self {
self.event_handlers.push(event_handler_arc);
pub fn event_handler<H>(mut self, event_handler: impl Into<Arc<H>>) -> Self
where
H: EventHandler + 'static,
{
self.event_handlers.push(event_handler.into());

self
}
Expand Down

0 comments on commit 062972b

Please sign in to comment.