Skip to main content

luaur_analysis/methods/
reasonings_to_string.rs

1use alloc::string::String;
2
3use crate::records::reasonings::Reasonings;
4
5impl Reasonings {
6    pub fn to_string(&mut self) -> String {
7        if self.reasons.is_empty() {
8            return String::new();
9        }
10
11        self.reasons.sort();
12
13        let mut all_reasons = if self.reasons.len() < 2 {
14            String::from("\n")
15        } else {
16            String::from("\nthis is because ")
17        };
18
19        for reason in &self.reasons {
20            if self.reasons.len() > 1 {
21                all_reasons.push_str("\n\t * ");
22            }
23            all_reasons.push_str(reason);
24        }
25
26        all_reasons
27    }
28}