You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: lib.rs
    path of file: ./repos/linfa/algorithms/linfa-hierarchical/src
    
    the code of the file until where you have to start completion: //! # Hierarchical Clustering
//!
//! `linfa-hierarchical` provides an implementation of agglomerative hierarchical clustering.
//! In this clustering algorithm, each point is first considered as a separate cluster. During each
//! step, two points are merged into ne
    
    fn check_ref(&self) -> std::result::Result<&Self::Checked, Self::Error> {
        match self.0.stopping {
            Criterion::NumClusters(x) if x == 0 => Err(
                HierarchicalError::InvalidStoppingCondition(self.0.stopping.clone()),
            ),
            Criterion::Distance(x) if x.is_negative() || x.is_nan() || x.is_infinite() => Err(
                HierarchicalError::InvalidStoppingCondition(self.0.stopping.clone()),
            ),
            _ => Ok(&self.0),
        }
    }