Function stremio_core::models::common::compare_with_priorities

source ·
pub fn compare_with_priorities<T: Ord + Hash + Eq + ?Sized>(
    a: &T,
    b: &T,
    priorities: &HashMap<&T, i32>,
) -> Ordering
Expand description

Compare a and b based on provided priority. Priorities should be set based on the type T and i32.

§Examples

use std::{cmp::Ordering, collections::HashMap};
use stremio_core::{constants::TYPE_PRIORITIES, models::common::compare_with_priorities};


let priorities = vec![("movie", 4), ("series", 3)]
    .into_iter()
    .collect::<HashMap<&str, i32>>();

let actual = compare_with_priorities("movie", "series", &priorities);
assert_eq!(Ordering::Greater, actual);