Resolve: Remove remove_custom_resolver

This commit is contained in:
Serial 2022-08-02 21:48:50 -04:00
parent 390512bda3
commit a08b47bf31
No known key found for this signature in database
GPG key ID: DA95198DC17C4568

View file

@ -95,7 +95,7 @@ impl<T: FileResolver> ObjectSafeFileResolver for GhostlyResolver<T> {
/// ///
/// # Panics /// # Panics
/// ///
/// * Attempting to register an existing name or type (See [`remove_custom_resolver`]) /// * Attempting to register an existing name or type
/// * See [`Mutex::lock`] /// * See [`Mutex::lock`]
pub fn register_custom_resolver<T: FileResolver + 'static>(name: &'static str) { pub fn register_custom_resolver<T: FileResolver + 'static>(name: &'static str) {
let mut res = CUSTOM_RESOLVERS.lock().unwrap(); let mut res = CUSTOM_RESOLVERS.lock().unwrap();
@ -111,23 +111,6 @@ pub fn register_custom_resolver<T: FileResolver + 'static>(name: &'static str) {
res.insert(name, Box::leak::<'static>(b)); res.insert(name, Box::leak::<'static>(b));
} }
/// Remove a registered file resolver
///
/// # Panics
///
/// See [`Mutex::lock`]
pub fn remove_custom_resolver(name: &'static str) {
let mut resolvers = CUSTOM_RESOLVERS.lock().unwrap();
if let Some(res) = resolvers.remove(name) {
unsafe {
#[allow(trivial_casts)]
let b = Box::from_raw(res as *const _ as *mut dyn ObjectSafeFileResolver);
drop(b);
}
}
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::id3::v2::ID3v2Tag; use crate::id3::v2::ID3v2Tag;