You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently struggling with converting StringOSMObj to an ArcOSMObj. My intuition is that it shouldn't be a problem, as I already was able to stream objects from an PBFReader to an XMLWriter. And of course there is the OSMObj trait.
My problem boils down to this: I want to write a test for a function show_id that in production only processes ArcOSMObj from an PBFReader. However for the test I'd like to be able to write xml, as it is more convenient. I have no problem with putting the trait OSMObj into show_id's type signature instead of ArcOSMObj.
$ rustc --version
rustc 1.55.0
$ cargo test
Compiling cast_test v0.1.0 (/home/kerstin/fh/cityvis/camps/osm-history/cast_test)
error[E0038]: the trait `OSMObj` cannot be made into an object
--> src/main.rs:3:17
|
3 | fn show_id(obj: dyn OSMObj) -> ObjId {
| ^^^^^^^^^^ `OSMObj` cannot be made into an object
|
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> /home/kerstin/.cargo/registry/src/github.com-1ecc6299db9ec823/osmio-0.6.0/src/lib.rs:285:23
|
285 | pub trait OSMObjBase: PartialEq + Debug + Clone {
| ^^^^^^^^^ the trait cannot be made into an object because it uses `Self` as a type parameter
For more information about this error, try `rustc --explain E0038`.
error: could not compile `cast_test` due to previous error
Any ideas on how to achieve this?
The text was updated successfully, but these errors were encountered:
Thanks for this great piece of software.
I'm currently struggling with converting
StringOSMObj
to anArcOSMObj
. My intuition is that it shouldn't be a problem, as I already was able to stream objects from anPBFReader
to anXMLWriter
. And of course there is theOSMObj
trait.My problem boils down to this: I want to write a test for a function
show_id
that in production only processesArcOSMObj
from anPBFReader
. However for the test I'd like to be able to write xml, as it is more convenient. I have no problem with putting the traitOSMObj
intoshow_id
's type signature instead ofArcOSMObj
.However this doesn't compile:
Any ideas on how to achieve this?
The text was updated successfully, but these errors were encountered: