Skip to main content

pick

Function pick 

Source
pub fn pick(fields: &BTreeMap<String, Vec<String>>, order: &[Pick]) -> Picked
Expand description

Tries each of order against fields, first to last: the first that finds one value decides, one that finds two different values is Picked::Ambiguous, and none finding any is Picked::Absent.

use std::collections::BTreeMap;
use coqui_access_kit::pick::{Pick, Picked, pick};

let fields = BTreeMap::from([("san.upn".to_owned(), vec!["alice@EXAMPLE.org".to_owned()])]);
let found = pick(&fields, &[Pick::new("san.email", "email"), Pick::new("san.upn", "name").domain("example.org")]);
assert_eq!(found, Picked::Found { by: "name".into(), value: "alice".into() });