Skip to content

following tutorial results in failed compile #20967

@lailoken503

Description

@lailoken503

First portion of the tutorial has us doing:

extern crate semver;

use semver::Version;

fn main() {
    assert!(Version::parse("1.2.3") == Ok(Version {
        major: 1u,
        minor: 2u,
        patch: 3u,
        pre: vec!(),
        build: vec!(),
    }));

    println!("Versions compared successfully!");
}

results in a failed compile:

/home/clayton/rust/tutorial/hello_world/src/main.rs:7:16: 7:18 error: mismatched types: expected `u64`, found `usize` (expected u64, found usize)
/home/clayton/rust/tutorial/hello_world/src/main.rs:7         major: 1u,
                                                                     ^~

Trying the suggested fix per compiler:

/home/clayton/rust/tutorial/hello_world/src/main.rs:7:16: 7:19 error: mismatched types: expected `u64`, found `usize` (expected u64, found usize)
/home/clayton/rust/tutorial/hello_world/src/main.rs:7         major: 1us,
                                                                     ^~~

However, per a post on reddit/r/rust/ it was suggested that I try u64 instead, which works.

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