wokket / rust-hl7

Learning rust by playing with a HL7 parser. Use for real at your own risk!
18 stars 8 forks source link

Feature/from str #19

Closed sempervictus closed 3 years ago

sempervictus commented 3 years ago

Merges the parallel work we both started doing into a single implementation providing both by wrapping from with try_from to deliver raw and wrapped results.

sempervictus commented 3 years ago

Interesting, cargo test does not like the From and TryFrom - conflicts with Core, supposedly:

$ cargo test
   Compiling rust-hl7 v0.3.0 (/opt/code/Rust/rust-hl7)
error[E0119]: conflicting implementations of trait `std::convert::TryFrom<&str>` for type `message::Message<'_>`
   --> src/message.rs:113:1
    |
113 | impl<'a> TryFrom<&'a str> for Message<'a> {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: conflicting implementation in crate `core`:
            - impl<T, U> TryFrom<U> for T
              where U: Into<T>;

error[E0119]: conflicting implementations of trait `std::convert::TryFrom<&str>` for type `message::Message<'_>`
   --> src/message.rs:113:1
    |
113 | impl<'a> TryFrom<&'a str> for Message<'a> {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: conflicting implementation in crate `core`:
            - impl<T, U> std::convert::TryFrom<U> for T
              where U: Into<T>;

error: aborting due to previous error

For more information about this error, try `rustc --explain E0119`.
error: could not compile `rust-hl7`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: aborting due to previous error

For more information about this error, try `rustc --explain E0119`.
error: build failed

which seems to be this issue - looking into "specialization" (always fun to learn something new :) ).

sempervictus commented 3 years ago

Confusing. The more specificity i add the more confusing the compiler errors get. I guess we either have to choose from() or try_from() - thoughts?