dtolnay/cxx

CxxVector<*mut Thing>

開放

#795 建立於 2021年3月29日

 (4 則留言) (0 個反應) (0 位負責人)Rust (253 個分叉)batch import
help wanted

倉庫指標

星標
 (4,472 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

I had a crack at implementing CxxVector<*mut T> and CxxVector<*const T> here:

https://github.com/dtolnay/cxx/compare/master...adetaylor:ptr-vecs-wip

It didn't work out too well, (I think) because we try to impl ::cxx::private::VectorElement for *const BlobstoreClient and the orphan rule doesn't appear to allow us to do this.

error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
  --> demo/src/main.rs:26:33
   |
1  | #[cxx::bridge(namespace = "org::blobstore")]
   | -------------------------------------------- `*const BlobstoreClient` is not defined in the current crate
...
26 |                 fn foo(n: u64) -> UniquePtr<CxxVector<*const BlobstoreClient>>;
   |                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use only types from inside the current crate
   |
   = note: define and implement a trait or new type instead

error: aborting due to previous error

For more information about this error, try `rustc --explain E0117`.

I may have the wrong idea for what went wrong here, but it looks like RFC1023 does indeed mention references but not pointers.

I'm unlikely to come back to this any time soon but thought I'd report my findings.

貢獻者指南