pub fn from_str(handle_name: &str, value: &str) -> Result<Self, String> {
        let re = Regex::new(REGEX_ID_CAPTURE).unwrap();
        if let Some(caps) = re.captures(value) {
            match (
                caps.name(CAPTURE_CONTEXT_NAME),
                caps.name(CAPTURE_ELEMENT_KEY),
            ) {
                (Some(context_name), Some(element_key)) => Ok(Handle {
                    context: context_name.as_str().to_string(),
                    key: element_key.as_str().to_string(),
                }),
                (None, _) => Err(format!(
                    "{} does not have a context: {:?}",
                    handle_name, value
                )),
                (_, None) => Err(format!("{} does not have a key: {:?}", handle_name, value)),
            }
        } else {
            Err(format!("Invalid {}: {:?}", handle_name, value))
        }
    }
/// Tries to create a `Handle` from a handle name and value.
Tries to create a `Handle` from a handle name and value.
Tries to create a ` Handle ` from a handle name and value .
pub fn from_str(handle_name: &str, value: &str) -> Result<Self, String> {
        let re = Regex::new(REGEX_ID_CAPTURE).unwrap();
        if let Some(caps) = re.captures(value) {
            match (
                caps.name(CAPTURE_CONTEXT_NAME),
                caps.name(CAPTURE_ELEMENT_KEY),
            ) {
                (Some(context_name), Some(element_key)) => Ok(Handle {
                    context: context_name.as_str().to_string(),
                    key: element_key.as_str().to_string(),
                }),
                (None, _) => Err(format!(
                    "{} does not have a context: {:?}",
                    handle_name, value
                )),
                (_, None) => Err(format!("{} does not have a key: {:?}", handle_name, value)),
            }
        } else {
            Err(format!("Invalid {}: {:?}", handle_name, value))
        }
    }
pub fn from_str ( handle_name : & str , value : & str ) -> Result < Self , String > { let re = Regex :: new ( REGEX_ID_CAPTURE ) . unwrap ( ) ; if let Some ( caps ) = re . captures ( value ) { match ( caps . name ( CAPTURE_CONTEXT_NAME ) , caps . name ( CAPTURE_ELEMENT_KEY ) , ) { ( Some ( context_name ) , Some ( element_key ) ) => Ok ( Handle { context : context_name . as_str ( ) . to_string ( ) , key : element_key . as_str ( ) . to_string ( ) , } ) , ( None , _ ) => Err ( format ! ( " " handle_name value ) ) , ( _ , None ) => Err ( format ! ( " " handle_name value ) ) , } } else { Err ( format ! ( " " handle_name value ) ) } }
Tries to create a `Handle` from a handle name and value.
Tries to create a ` Handle ` from a handle name and value .
handle_name
&str
value
&str
handle_name
&str
value
&str