Skip to content

Standardize on self-containedness of examples in docs. #9403

Closed
@huonw

Description

@huonw

There are many examples in the docs that require some adjustments to get to compile, e.g. the following requires a main function:

let a = [0];
let b = [1];
let mut it = a.iter().chain(b.iter());
assert_eq!(it.next().get(), &0);
assert_eq!(it.next().get(), &1);
assert!(it.next().is_none());

(Iterator.chain at the time of filing.)

And others that are entirely self-contained, and can just be copy-pasted to be run.

use std::rand;

fn main () {
    let tuple_ptr = rand::random::<~(f64, char)>();
    printfln!(tuple_ptr)
}

(One of the examples at the top of std::rand.)

It seems like it would be good to be consistent about this. I prefer the latter, and it would make automatically running the tests much easier (#2925).

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