pub fn instance_apply<T: 'static, R, F: FnOnce(&Configuration<T>) -> R>(
    id: &Identifier,
    f: F,
) -> Result<R> {
    match lock(&SINGLETONS).get(id) {
        Some(instance) => match instance.downcast_ref() {
            Some(config) => Ok(f(config)),
            None => {
                return Err(Error::InvalidArgument(format!(
                    "wrong type specified for configuration {:?}",
                    id
                )));
            }
        },
        None => {
            return Err(Error::InvalidArgument(format!(
                "unrecognized configuration identifier: {:?}",
                id
            )));
        }
    }
}
/// instance_apply is a very generic function which applies the given function
/// to the configuration singleton matching the given identifier. It is an error
/// if the identifier is unrecognized, or if the given callback operates on a
/// Configuration of the wrong type.
instance_apply is a very generic function which applies the given function
to the configuration singleton matching the given identifier. It is an error
if the identifier is unrecognized, or if the given callback operates on a
Configuration of the wrong type.
instance_apply is a very generic function which applies the given function to the configuration singleton matching the given identifier . It is an error if the identifier is unrecognized or if the given callback operates on a Configuration of the wrong type .
pub fn instance_apply<T: 'static, R, F: FnOnce(&Configuration<T>) -> R>(
    id: &Identifier,
    f: F,
) -> Result<R> {
    match lock(&SINGLETONS).get(id) {
        Some(instance) => match instance.downcast_ref() {
            Some(config) => Ok(f(config)),
            None => {
                return Err(Error::InvalidArgument(format!(
                    "wrong type specified for configuration {:?}",
                    id
                )));
            }
        },
        None => {
            return Err(Error::InvalidArgument(format!(
                "unrecognized configuration identifier: {:?}",
                id
            )));
        }
    }
}
pub fn instance_apply < T : ' static , R , F : FnOnce ( & Configuration < T > ) -> R > ( id : & Identifier , f : F , ) -> Result < R > { match lock ( & SINGLETONS ) . get ( id ) { Some ( instance ) => match instance . downcast_ref ( ) { Some ( config ) => Ok ( f ( config ) ) , None => { return Err ( Error :: InvalidArgument ( format ! ( " " id ) ) ) ; } } , None => { return Err ( Error :: InvalidArgument ( format ! ( " " id ) ) ) ; } } }
instance_apply is a very generic function which applies the given function
to the configuration singleton matching the given identifier.
instance_apply is a very generic function which applies the given function to the configuration singleton matching the given identifier .
id
&Identifier
f
F
id
&Identifier
f
F