use super::{Unversioned, Version, Versioned};

impl<V, U> Version<V, U>
where
    V: Versioned,
    U: Unversioned<Versioned = V>,
{
    /// Return the `Versioned` object if the `Version` is `Certain`.
    ///
    /// # Panics
    ///
    /// Will panic if the `Version` is `Uncertain`.
    pub fn unwrap_certain(self) -> V {
        match self {
            Version::Certain(v) => v,
            Version::Uncertain(_) => {
                let type_name = std::any::type_name::<V>();
                panic!("The version of `{type_name}` is unknown")
            }
        }
    }
}
