<commit_before>use std::mem::size_of_val;

// This function borrows a slice
fn analize_slice(slice: &[int]) {
    println!("first element of the slice: {}", slice[0]);
    println!("the slice has {} elements", slice.len());
}

fn main() {
    // fixed-size array (type signature is superfluous)
    let xs: [int, ..5] = [1, 2, 3, 4, 5];

    // indexing starts at 0
    println!("first element of the array: {}", xs[0]);
    println!("second element of the array: {}", xs[1]);

    // len() returns the size of the array
    println!("array size: {}", xs.last());

    // arrays are stack allocated
    println!("array occupies {} bytes", size_of_val(&xs));

    // out of bound indexing yields a runtime failure
    //println!("{}", xs[5]);

    // arrays can be automatically converted to slices
    println!("borrow the whole array as an slice");
    analize_slice(xs);

    // slices can point to a section of an array
    println!("borrow a section of the array as an slice");
    analize_slice(xs.slice(1, 4));
}
<commit_msg>Fix minor spelling mistake in example function.<commit_after>use std::mem::size_of_val;

// This function borrows a slice
fn analyze_slice(slice: &[int]) {
    println!("first element of the slice: {}", slice[0]);
    println!("the slice has {} elements", slice.len());
}

fn main() {
    // fixed-size array (type signature is superfluous)
    let xs: [int, ..5] = [1, 2, 3, 4, 5];

    // indexing starts at 0
    println!("first element of the array: {}", xs[0]);
    println!("second element of the array: {}", xs[1]);

    // len() returns the size of the array
    println!("array size: {}", xs.last());

    // arrays are stack allocated
    println!("array occupies {} bytes", size_of_val(&xs));

    // out of bound indexing yields a runtime failure
    //println!("{}", xs[5]);

    // arrays can be automatically converted to slices
    println!("borrow the whole array as an slice");
    analyze_slice(xs);

    // slices can point to a section of an array
    println!("borrow a section of the array as an slice");
    analyze_slice(xs.slice(1, 4));
}

{'fraction_non_alphanumeric': 0.15601145038167938, 'fraction_numerical': 0.012404580152671756, 'mean_word_length': 3.2278225806451615, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5130399', 'n_tokens_mistral': 665, 'n_tokens_neox': 631, 'n_words': 240}