Skip to content

Chapter 03 - error[E0308] & error[E0277] #5

@tmollov

Description

@tmollov

Hi, people

While i was starting the file_transfer_stub project from the chapter,
cargo run gave me 2 errors:

error[E0277]: cannot subtract `chrono::Duration` from `Tm`
   --> /home/tmollov/.cargo/registry/src/index.crates.io-6f17d22bba15001f/actix-http-0.2.11/src/cookie/jar.rs:226:44
    |
226 |             cookie.set_expires(time::now() - Duration::days(365));
    |                                            ^ no implementation for `Tm - chrono::Duration`
    |
    = help: the trait `Sub<chrono::Duration>` is not implemented for `Tm`
    = help: the following other types implement trait `Sub<Rhs>`:
              <Tm as Sub<time::Duration>>
              <Tm as Sub>

error[E0308]: mismatched types
   --> /home/tmollov/.cargo/registry/src/index.crates.io-6f17d22bba15001f/actix-http-0.2.11/src/cookie/mod.rs:742:40
    |
742 |         self.set_expires(time::now() + twenty_years);
    |                                        ^^^^^^^^^^^^ expected `time::Duration`, found `chrono::Duration`
    |
    = note: `chrono::Duration` and `time::Duration` have similar names, but are actually distinct types
note: `chrono::Duration` is defined in crate `chrono`
   --> /home/tmollov/.cargo/registry/src/index.crates.io-6f17d22bba15001f/chrono-0.4.31/src/duration.rs:55:1
    |
55  | pub struct Duration {
    | ^^^^^^^^^^^^^^^^^^^
note: `time::Duration` is defined in crate `time`
   --> /home/tmollov/.cargo/registry/src/index.crates.io-6f17d22bba15001f/time-0.1.45/src/duration.rs:45:1
    |
45  | pub struct Duration {
    | ^^^^^^^^^^^^^^^^^^^

Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `actix-http` (lib) due to 2 previous errors

after a google search i understand that these libraries had some changes, but i can't find a way to fix these issues without some refactoring.

Is there any way without the refactoring?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions