How to use Vec<&str> as pyo3 struct field? #2128
-
|
It seems that the lifetime is not supported in pyo3, so what should I do if I need declare the struct field as
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
|
What you could normally use in Rust for such cases is What about |
Beta Was this translation helpful? Give feedback.
What you could normally use in Rust for such cases is
Vec<Rc<str>>which avoids the duplicates. I don't think this can be directly be exposed to Python though.What about
Vec<Py<PyString>>? If you have to expose the strings to Python, you'll have to convert them to PyString at some point anyway, andPyis likeRcin that you can clone them by just making a new reference. Python strings are also immutable.