diff options
Diffstat (limited to '')
-rw-r--r-- | vendor/syn/src/path.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/vendor/syn/src/path.rs b/vendor/syn/src/path.rs index 883f179f5..b9d96e669 100644 --- a/vendor/syn/src/path.rs +++ b/vendor/syn/src/path.rs @@ -82,6 +82,19 @@ impl Path { None } } + + /// An error if this path is not a single ident, as defined in `get_ident`. + #[cfg(feature = "parsing")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] + pub fn require_ident(&self) -> Result<&Ident> { + self.get_ident().ok_or_else(|| { + crate::error::new2( + self.segments.first().unwrap().ident.span(), + self.segments.last().unwrap().ident.span(), + "expected this path to be an identifier", + ) + }) + } } ast_struct! { |