algorithmz 1.1.5

This is the corresponding implemenation of the python module of the same name.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/// Repeat substring
///
/// Given a non-empty string, check if it can be constructed by taking a substring of it and appending multiple copies of the substring together.
///
/// # Examples
///
/// Basic usage:
/// ``` 
/// let result = algorithmz::string::repeat_substring("abab");
/// assert_eq!(result, true);
/// ```
pub fn repeat_substring(text: &str) -> bool {
    let doubled = format!("{}{}", text, text);

    let trimmed = &doubled[1..doubled.len() - 1];

    trimmed.contains(text)
}