Repository navigation
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
|
Answered by
birkenfeld
Jan 26, 2022
Replies: 1 comment 5 replies
|
What you could normally use in Rust for such cases is What about |
5 replies
Answer selected by
tushushu
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.