pub fn random_item_from_category(cat: &str) -> Result<Item, Error> {
    let items: ItemList = serde_json::from_str(&open_file("items")?)?;
    let sub = match cat {
        "boots" => items.boots,
        "common" => items.common,
        "ranged" => items.ranged,
        "melee" => items.melee,
        "jungle" => items.jungle,
        "support" => items.support,
        "classic" => items.classic,
        "rift" => items.rift,
        "abyss" => items.abyss,
        "treeline" => items.treeline,
        "featured" => items.featured,
        "Ornn" | "ornn" => items.special.ornn,
        "Viktor" | "viktor" => items.special.viktor,
        "other" => items.special.other,
        _ => Vec::new(),
    };

    let mut rng = rand::thread_rng();
    Ok(rng.choose(&sub).unwrap().clone())
}
/// Returns a single random item from a given category. Used primarily for boots, jungle, and special items.
Returns a single random item from a given category. Used primarily for boots, jungle, and special items.
Returns a single random item from a given category . Used primarily for boots jungle and special items .
pub fn random_item_from_category(cat: &str) -> Result<Item, Error> {
    let items: ItemList = serde_json::from_str(&open_file("items")?)?;
    let sub = match cat {
        "boots" => items.boots,
        "common" => items.common,
        "ranged" => items.ranged,
        "melee" => items.melee,
        "jungle" => items.jungle,
        "support" => items.support,
        "classic" => items.classic,
        "rift" => items.rift,
        "abyss" => items.abyss,
        "treeline" => items.treeline,
        "featured" => items.featured,
        "Ornn" | "ornn" => items.special.ornn,
        "Viktor" | "viktor" => items.special.viktor,
        "other" => items.special.other,
        _ => Vec::new(),
    };
    let mut rng = rand::thread_rng();
    Ok(rng.choose(&sub).unwrap().clone())
}
pub fn random_item_from_category ( cat : & str ) -> Result < Item , Error > { let items : ItemList = serde_json :: from_str ( & open_file ( " " ) ? ) ? ; let sub = match cat { " " => items . boots , " " => items . common , " " => items . ranged , " " => items . melee , " " => items . jungle , " " => items . support , " " => items . classic , " " => items . rift , " " => items . abyss , " " => items . treeline , " " => items . featured , " " | " " => items . special . ornn , " " | " " => items . special . viktor , " " => items . special . other , _ => Vec :: new ( ) , } ; let mut rng = rand :: thread_rng ( ) ; Ok ( rng . choose ( & sub ) . unwrap ( ) . clone ( ) ) }
Returns a single random item from a given category.
Returns a single random item from a given category .
cat
&str
cat
&str