(&mut self, target: &[String])
| 835 | } |
| 836 | |
| 837 | fn qualify(&mut self, target: &[String]) { |
| 838 | let mut same = 0; |
| 839 | // itertools::fold_while? |
| 840 | for (a, b) in self.namespace.iter().zip(target.iter()) { |
| 841 | if a == b { |
| 842 | same += 1; |
| 843 | } else { |
| 844 | break; |
| 845 | } |
| 846 | } |
| 847 | if same == 0 && !target.is_empty() { |
| 848 | // if the root namespace exists below the current namespace we need to start at root |
| 849 | // Also ensure absolute qualification when crossing from exports to imports |
| 850 | if self.namespace.contains(target.first().unwrap()) |
| 851 | || (self.namespace.first().map(|s| s.as_str()) == Some("exports") |
| 852 | && target.first().map(|s| s.as_str()) != Some("exports")) |
| 853 | { |
| 854 | self.src.push_str("::"); |
| 855 | } |
| 856 | } |
| 857 | if same == target.len() && self.namespace.len() != target.len() && same > 0 { |
| 858 | // namespace is parent, qualify at least one namespace (and cross fingers) |
| 859 | uwrite!(self.src, "{}::", target[same - 1]); |
| 860 | } else { |
| 861 | for i in target.iter().skip(same) { |
| 862 | uwrite!(self.src, "{i}::"); |
| 863 | } |
| 864 | } |
| 865 | } |
| 866 | } |
| 867 | |
| 868 | struct CppInterfaceGenerator<'a> { |
no test coverage detected