Build the body lines for an enum hover showing its cases. Only enum cases are shown (not regular class constants). Each case is rendered as ` case Name = 'value';` or ` case Name;`. If there are more than [`MAX_BODY_ITEMS`] cases, the list is truncated with a `// and N more…` comment.
(cls: &ClassInfo)
| 1655 | /// If there are more than [`MAX_BODY_ITEMS`] cases, the list is truncated |
| 1656 | /// with a `// and N more…` comment. |
| 1657 | fn build_enum_case_body(cls: &ClassInfo) -> String { |
| 1658 | let cases: Vec<&ConstantInfo> = cls.constants.iter().filter(|c| c.is_enum_case).collect(); |
| 1659 | |
| 1660 | if cases.is_empty() { |
| 1661 | return String::new(); |
| 1662 | } |
| 1663 | |
| 1664 | let mut body = String::new(); |
| 1665 | let shown = cases.len().min(MAX_BODY_ITEMS); |
| 1666 | |
| 1667 | for case in &cases[..shown] { |
| 1668 | if let Some(ref val) = case.enum_value { |
| 1669 | body.push_str(&format!(" case {} = {};\n", case.name, val)); |
| 1670 | } else { |
| 1671 | body.push_str(&format!(" case {};\n", case.name)); |
| 1672 | } |
| 1673 | } |
| 1674 | |
| 1675 | if cases.len() > MAX_BODY_ITEMS { |
| 1676 | body.push_str(&format!( |
| 1677 | " // and {} more…\n", |
| 1678 | cases.len() - MAX_BODY_ITEMS |
| 1679 | )); |
| 1680 | } |
| 1681 | |
| 1682 | body |
| 1683 | } |
| 1684 | |
| 1685 | /// Build the body lines for a trait hover showing public member signatures. |
| 1686 | /// |
no test coverage detected