From d0fe0a14cd9dec2d98c15aa24778b92f5b8be2b6 Mon Sep 17 00:00:00 2001 From: Bulat Kurbanov Date: Sat, 27 May 2023 22:50:25 +0200 Subject: [PATCH] Fix --- .../services/book_library/formaters.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/bots/approved_bot/services/book_library/formaters.rs b/src/bots/approved_bot/services/book_library/formaters.rs index 2cab746..ebfe270 100644 --- a/src/bots/approved_bot/services/book_library/formaters.rs +++ b/src/bots/approved_bot/services/book_library/formaters.rs @@ -52,7 +52,9 @@ fn format_authors(authors: Vec, count: usize) -> String { .map(|author| author.format_inline()) .collect::>() .join("\n"); - format!("Авторы:\n{formated_authors}\n") + + let post_fix = if authors.len() > count { "\nи др." } else { "" }; + format!("Авторы:\n{formated_authors}{post_fix}\n") } false => "".to_string(), } @@ -66,7 +68,9 @@ fn format_translators(translators: Vec, count: usize) -> String { .map(|translator| translator.format_inline()) .collect::>() .join("\n"); - format!("Переводчики:\n{formated_translators}\n") + + let post_fix = if translators.len() > count { "\nи др." } else { "" }; + format!("Переводчики:\n{formated_translators}{post_fix}\n") } false => "".to_string(), } @@ -80,7 +84,9 @@ fn format_sequences(sequences: Vec, count: usize) -> String { .map(|sequence| sequence.format(NO_LIMIT)) .collect::>() .join("\n"); - format!("Серии:\n{formated_sequences}\n") + + let post_fix = if sequences.len() > count { "\nи др." } else { "" }; + format!("Серии:\n{formated_sequences}{post_fix}\n") } false => "".to_string(), } @@ -94,7 +100,9 @@ fn format_genres(genres: Vec, count: usize) -> String { .map(|genre| genre.format()) .collect::>() .join("\n"); - format!("Жанры:\n{formated_genres}\n") + + let post_fix = if genres.len() > count { "\nи др." } else { "" }; + format!("Жанры:\n{formated_genres}{post_fix}\n") } false => "".to_string(), }