receiverChain.
(e: &MExpr)
| 1887 | |
| 1888 | /// receiverChain. |
| 1889 | fn macro_receiver_chain(e: &MExpr) -> Option<String> { |
| 1890 | let mut links: Vec<String> = Vec::new(); |
| 1891 | let mut cur = e; |
| 1892 | while links.len() <= RECEIVER_CHAIN_MAX_LINKS { |
| 1893 | match cur { |
| 1894 | MExpr::SelfE | MExpr::Name(_) => { |
| 1895 | let root = match cur { |
| 1896 | MExpr::Name(n) => n.as_str(), |
| 1897 | _ => "self", |
| 1898 | }; |
| 1899 | if links.is_empty() || !is_rust_ident(root) { |
| 1900 | return None; |
| 1901 | } |
| 1902 | links.reverse(); |
| 1903 | let mut s = root.to_string(); |
| 1904 | for l in links { |
| 1905 | s.push('.'); |
| 1906 | s.push_str(&l); |
| 1907 | } |
| 1908 | return Some(s); |
| 1909 | } |
| 1910 | MExpr::Method(b, n) => { |
| 1911 | if !is_rust_ident(n) { |
| 1912 | return None; |
| 1913 | } |
| 1914 | links.push(format!("{n}()")); |
| 1915 | cur = &**b; |
| 1916 | } |
| 1917 | MExpr::Field(b, n) => { |
| 1918 | if !is_field_text(n) { |
| 1919 | return None; |
| 1920 | } |
| 1921 | links.push(n.clone()); |
| 1922 | cur = &**b; |
| 1923 | } |
| 1924 | _ => return None, |
| 1925 | } |
| 1926 | } |
| 1927 | None |
| 1928 | } |
| 1929 | |
| 1930 | /// methodCallName. |
| 1931 | fn macro_method_call_name(base: &MExpr, method: &str) -> Option<String> { |
no test coverage detected