Add automated warning and banning
This commit is contained in:
@@ -54,3 +54,21 @@ pub trait Bye: Sized {
|
||||
}
|
||||
|
||||
impl<T> Bye for T {}
|
||||
|
||||
/// Trims a string to a maximum length, adding an ellipsis if it exceeds the limit.
|
||||
///
|
||||
/// Arguments:
|
||||
/// * `string` - The string to trim with ellipse.
|
||||
/// * `max_length` - The max length the string may have.
|
||||
///
|
||||
/// Returns:
|
||||
/// [`String`] - The trimmed string with an ellipsis if it exceeded the limit.
|
||||
pub fn ellipse(string: String, max_length: usize) -> String {
|
||||
if string.len() <= max_length {
|
||||
string
|
||||
} else {
|
||||
let len = max_length.saturating_sub(3);
|
||||
|
||||
format!("{}...", &string[..len])
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user