aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mssola@mssola.com>2026-01-19 21:48:32 +0100
committerMiquel Sabaté Solà <mssola@mssola.com>2026-01-19 22:01:36 +0100
commite1e7a94d0c781fa3c8a3c82a74c671ee1e92af92 (patch)
tree656137442ca8a1b6d1daf3c11296fd403779c088 /lib
parent19d7c1eab58d9f02e41f831eda121ef587487858 (diff)
downloadmihi-e1e7a94d0c781fa3c8a3c82a74c671ee1e92af92.tar.gz
mihi-e1e7a94d0c781fa3c8a3c82a74c671ee1e92af92.zip
run: ask for alternatives as well
This commit also fixes the need to ask for a random gender when asking for adjectives. This is somewhat unrelated to the main subject, but untying this now was a bit too much of a hassle. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/mihi/src/lib.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/mihi/src/lib.rs b/lib/mihi/src/lib.rs
index 7555a0f..d75965d 100644
--- a/lib/mihi/src/lib.rs
+++ b/lib/mihi/src/lib.rs
@@ -300,18 +300,18 @@ impl TryFrom<isize> for RelationKind {
}
/// Join by enunciate the given words.
-pub fn joint_related_words(related: &Vec<Word>) -> String {
- return related
+pub fn joint_related_words(related: &[Word]) -> String {
+ related
.iter()
.map(|w| w.enunciated.clone())
.collect::<Vec<String>>()
- .join("; ");
+ .join("; ")
}
/// Returns a string with the enunciate of the comparative form of the given
/// `word`. This function assumes that it really does, or at least it's
/// contained in the `related` vector.
-pub fn comparative(word: &Word, related: &Vec<Word>) -> String {
+pub fn comparative(word: &Word, related: &[Word]) -> String {
if !related.is_empty() {
return joint_related_words(related);
}
@@ -326,7 +326,7 @@ pub fn comparative(word: &Word, related: &Vec<Word>) -> String {
/// Returns a string with the enunciate of the superlative form of the given
/// `word`. This function assumes that it really does, or at least it's
/// contained in the `related` vector.
-pub fn superlative(word: &Word, related: &Vec<Word>) -> String {
+pub fn superlative(word: &Word, related: &[Word]) -> String {
if !related.is_empty() {
return joint_related_words(related);
}
@@ -346,7 +346,7 @@ pub fn superlative(word: &Word, related: &Vec<Word>) -> String {
/// Returns a string with the enunciate of the adverbial form of the given
/// `word`. This function assumes that it really does, or at least it's
/// contained in the `related` vector.
-pub fn adverb(word: &Word, related: &Vec<Word>) -> String {
+pub fn adverb(word: &Word, related: &[Word]) -> String {
if !related.is_empty() {
return joint_related_words(related);
}
@@ -439,7 +439,7 @@ impl Word {
if self.is_flag_set("contracted_root") {
return format!(
"{}{}",
- self.particle[0..(self.particle.len() - 2)].to_string(),
+ &self.particle[0..(self.particle.len() - 2)],
self.particle.chars().last().unwrap_or(' '),
);
}