### Iterate over all scripts with Script::all() Source: https://docs.rs/whatlang/latest/whatlang/enum.Script.html Example usage of the all() method to iterate over all existing scripts and print them. ```rust use whatlang::Script; for script in Script::all() { println!("{}", script); } ``` -------------------------------- ### Detector struct implementation with allowlist and denylist examples Source: https://docs.rs/whatlang/latest/src/whatlang/core/detector.rs.html The full source code of the Detector struct, including constructors with_allowlist and with_denylist, and methods detect, detect_lang, and detect_script. The doc comments include examples for using with_allowlist and with_denylist. The code also includes unit tests for detect_script, detect_lang, and detect. ```rust use crate::Lang; use crate::core; use crate::core::FilterList; use crate::core::Info; use crate::core::Options; use crate::scripts::{Script, detect_script}; /// Configurable structure that holds detection options and provides functions /// to detect language and script. /// # Examples /// Specifying an allowlist: /// /// /// use whatlang::{Detector, Lang}; /// /// // Create detector with allowlist /// let detector = Detector::with_allowlist(vec![Lang::Eng, Lang::Rus]); /// let lang = detector.detect_lang("That is not Russian"); /// assert_eq!(lang, Some(Lang::Eng)); /// /// /// Specifying a blacklist: /// /// /// use whatlang::{Detector, Lang}; /// /// let detector = Detector::with_denylist(vec![Lang::Eng, Lang::Ita]); /// let lang = detector.detect_lang("Jen la trinkejo fermitis, ni iras tra mallumo kaj pluvo."); /// assert_eq!(lang, Some(Lang::Epo)); /// #[cfg_attr(feature = "arbitrary", derive(::arbitrary::Arbitrary))] #[derive(Debug, Clone, Default)] pub struct Detector { options: Options, } impl Detector { pub fn new() -> Self { Self::default() } pub fn with_allowlist(list: Vec) -> Self { let opts = Options::new().set_filter_list(FilterList::allow(list)); Self::with_options(opts) } pub fn with_denylist(list: Vec) -> Self { let opts = Options::new().set_filter_list(FilterList::deny(list)); Self::with_options(opts) } fn with_options(options: Options) -> Self { Detector { options } } pub fn detect(&self, text: &str) -> Option { core::detect_with_options(text, &self.options) } pub fn detect_lang(&self, text: &str) -> Option { core::detect_with_options(text, &self.options).map(|info| info.lang()) } pub fn detect_script(&self, text: &str) -> Option