open_pql/functions/cast/
to_card.rs

1use super::*;
2
3#[pqlfn(arg, rtn, eval)]
4pub fn to_card(s: &str) -> Result<PQLCard, RuntimeError> {
5    s.parse()
6        .map_or_else(|_| Err(RuntimeError::ToCardParseFailed(s.into())), Ok)
7}
8
9#[cfg(test)]
10mod tests {
11    use super::*;
12
13    #[test]
14    fn test_to_card() {
15        assert!(to_card(" 2H ").is_ok());
16        assert!(to_card("2h?").is_err());
17    }
18}