Skip to content

doc: how to run example, for n00bs #476

@coolaj86

Description

@coolaj86

Re: #475

  1. Make sure your rustc version is 1.61.0 or greater
    rustup update
    rustup override unset
    rustup default stable
    rustc --version
  2. Create a new project
    mkdir -p ./my-print-rcdom/
    pushd ./my-print-rcdom/
    cargo init
  3. Update Cargo.toml to include the dependencies (also, 2018 appears to be the required edition)
    [package]
    name = "example01"
    version = "0.1.0"
    authors = ["Joe Doe <joe@example.com>"]
    edition = "2018"
    
    # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
    
    [dependencies]
    html5ever = "0.25.2"
    markup5ever_rcdom = "0.1.0"
  4. Replace src/main.rs with the contents of, for example, ./rcdom/examples/print-rcdom.rs
    rm ./src/main.rs
    curl -L -o ./src/main.rs https://raw.githubusercontent.com/servo/html5ever/1b34cf17c/rcdom/examples/print-rcdom.rs
  5. Install, build, run (with input):
    cargo build
    curl https://example.com | cargo run

Troubleshooting

Weird bug:

warning: unused import: `html5ever::tendril::TendrilSink`
  --> src/main.rs:20:5
   |
20 | use html5ever::tendril::TendrilSink;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

Some errors have detailed explanations: E0277, E0599.
For more information about an error, try `rustc --explain E0277`.

Changing the name field in Cargo.toml (to anything at all), saving, and running cargo install again.

A room full of rust developers, including one of the most popular teachers on udemy in the room here with us, cannot figure this out.

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