Repository: dtolnay/cxx (language: rust)

Issue:
Allow namespace to be given as a quoted string
Currently the attribute macro requires namespace to be provided as:

```rust
#[cxx::bridge(namespace = my::path::to)]
mod ffi {
```

Some people find it easier for a human to parse if the kv's value is quoted, or just have muscle memory for that from before Rust allowed unquoted kv attrs. We might as well support both.

```rust
#[cxx::bridge(namespace = "my::path::to")]
mod ffi {
```


Discussion / hints:

Fix patch:
diff --git a/syntax/namespace.rs b/syntax/namespace.rs
index bdfb84530..49b31d14f 100644
--- a/syntax/namespace.rs
+++ b/syntax/namespace.rs
@@ -32,7 +32,9 @@ impl Parse for Namespace {
         if !input.is_empty() {
             input.parse::<kw::namespace>()?;
             input.parse::<Token![=]>()?;
-            segments = input.call(QualifiedName::parse_unquoted)?.segments;
+            segments = input
+                .call(QualifiedName::parse_quoted_or_unquoted)?
+                .segments;
             input.parse::<Option<Token![,]>>()?;
         }
         Ok(Namespace { segments })
diff --git a/syntax/qualified.rs b/syntax/qualified.rs
index a34009310..be9bceb43 100644
--- a/syntax/qualified.rs
+++ b/syntax/qualified.rs
@@ -1,6 +1,6 @@
 use syn::ext::IdentExt;
 use syn::parse::{ParseStream, Result};
-use syn::{Ident, Token};
+use syn::{Ident, LitStr, Token};
 
 pub struct QualifiedName {
     pub segments: Vec<Ident>,
@@ -23,4 +23,13 @@ impl QualifiedName {
         }
         Ok(QualifiedName { segments })
     }
+
+    pub fn parse_quoted_or_unquoted(input: ParseStream) -> Result<Self> {
+        if input.peek(LitStr) {
+            let lit: LitStr = input.parse()?;
+            lit.parse_with(Self::parse_unquoted)
+        } else {
+            Self::parse_unquoted(input)
+        }
+    }
 }


Test patch: