Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
test: doc test for iter_library_names
  • Loading branch information
CurryPseudo authored and Danielmelody committed Dec 1, 2020
1 parent 2c138fc commit 6351f39
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/interpreter/interpreter.rs
Expand Up @@ -112,6 +112,31 @@ impl<R: RealNumberInternalTrait, E: IEnvironment<R>> LibraryLoader<R, E> {
self.register_library_factory(library_factory);
self
}
/// iterate all registered library name in library loader
/// # Example
/// ```
/// use ruschm::library_name;
/// use ruschm::environment::StandardEnv;
/// use ruschm::interpreter::{LibraryLoader, LibraryFactory, library::LibraryName};
/// use std::collections::HashSet;
/// let library_loader = LibraryLoader::<f32, StandardEnv<_>>::new()
/// .with_lib_factory(LibraryFactory::Native(library_name!("foo"), || vec![]))
/// .with_lib_factory(LibraryFactory::Native(
/// library_name!("foo", "bar"),
/// || vec![],
/// ))
/// .with_lib_factory(LibraryFactory::Native(library_name!(0, "a"), || vec![]));
/// assert_eq!(
/// library_loader.iter_library_names().collect::<HashSet<_>>(),
/// vec![
/// &library_name!("foo"),
/// &library_name!("foo", "bar"),
/// &library_name!(0, "a")
/// ]
/// .into_iter()
/// .collect::<HashSet<_>>()
/// );
/// ```
pub fn iter_library_names(&self) -> impl Iterator<Item = &LibraryName> {
self.lib_factories.keys()
}
Expand Down

0 comments on commit 6351f39

Please sign in to comment.