anyinput/lib.rs
1#![warn(missing_docs)]
2#![doc = include_str!("../README.md")]
3
4/// A macro for easier writing of functions that accept any string-, path-, iterator-, array-, or ndarray-like input.
5/// The AnyInputs are `AnyString`, `AnyPath`, `AnyIter`, `AnyArray`, and (optionally) `AnyNdArray`.
6///
7/// See the [documentation](https://docs.rs/anyinput/) for for details.
8///
9/// # Example
10/// ```
11/// use anyinput::anyinput;
12///
13/// #[anyinput]
14/// fn len_plus_2(s: AnyString) -> usize {
15/// s.len()+2
16/// }
17///
18/// // By using AnyString, len_plus_2 works with
19/// // &str, String, or &String -- borrowed or moved.
20/// assert_eq!(len_plus_2("Hello"), 7); // move a &str
21/// let input: &str = "Hello";
22/// assert_eq!(len_plus_2(&input), 7); // borrow a &str
23/// let input: String = "Hello".to_string();
24/// assert_eq!(len_plus_2(&input), 7); // borrow a String
25/// let input2: &String = &input;
26/// assert_eq!(len_plus_2(&input2), 7); // borrow a &String
27/// assert_eq!(len_plus_2(input2), 7); // move a &String
28/// assert_eq!(len_plus_2(input), 7); // move a String
29/// ```
30pub use anyinput_derive::anyinput;