Skip to content

Instantly share code, notes, and snippets.

@GuillaumeGomez
Created June 12, 2024 21:29
Show Gist options
  • Save GuillaumeGomez/bd70f39aa4aa8ae7d0695330e4daecd8 to your computer and use it in GitHub Desktop.
Save GuillaumeGomez/bd70f39aa4aa8ae7d0695330e4daecd8 to your computer and use it in GitHub Desktop.
This file has been truncated, but you can view the full file.
#![allow(unused_extern_crates)]
#![allow(internal_features)]
#![feature(test)]
#![feature(rustc_attrs)]
#![feature(coverage_attribute)]
// First, we declare a type which has the `iter` method to get the `Iter`
// an infinite iterator has no upper bound
// so no need for `unsafe` here.
// We can derive a `Copy` implementation. `Clone` is also required, as it's
// First, we declare a type which has `iter_mut` method to get the `IterMut`
// Undefined behaviour
// You can extend a String with some chars:
// `derive` implements Clone for Reading<T> when T is Clone.
// slicing a Vec
// `UnsafeCell` is a transparent no-op wrapper,
// An invalid UTF-8 string
// elements to produce is the length of array down there: only arrays of
// a supertrait of `Copy`.
// type inference is helping us here, the way `from_fn` knows how many
// this panics
// the panic message for these assertions is the stringified value of the
// The `is_ok` and `is_err` methods do what they say.
// First, the struct:
// an iterator which alternates between Some and None
// equal lengths can be compared, so the const generic parameter `N` is
// A sample collection, that's just a wrapper over Vec<T>
// a finite range knows exactly how many times it will iterate
// this is not a good way to do this.
// Iterate using a raw pointer in increments of two elements (backwards)
// U+009C, STRING TERMINATOR
// expression given.
// The derive implements <BookFormat> == <BookFormat> comparisons
// Panics; from_u32 returns None.
// Iterate using a raw pointer in increments of two elements
// First, we declare a type which has `iter` method to get the `Iter` struct (`&[usize]` here):
// &str
// deprecated way
// inferred to be 5, thus creating array of 5 elements.
// Rust 2021:
// On some platforms, the alignment of i32 is less than 4.
// struct (`&[usize]` here):
// as chars
// 𝄞mus<invalid>ic<invalid>
// and the maximum possible lower bound
// The even numbers in the range of zero to nine.
// don't do this:
// Read environment variable, panic if it is not present
#![deny(warnings)]
#![allow(dead_code, deprecated, unused_variables, unused_mut)]
extern crate test;
mod __doctest_0 {
#[rustc_test_marker = "library/core/src/../../portable-simd/crates/core_simd/src/simd/prelude.rs - core_simd::simd::prelude (line 4)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/../../portable-simd/crates/core_simd/src/simd/prelude.rs - core_simd::simd::prelude (line 4)"),
ignore: true,
ignore_message: None,
source_file: "library/core/src/../../portable-simd/crates/core_simd/src/simd/prelude.rs",
start_line: 4,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_1 {
#[rustc_test_marker = "library/core/src/../../stdarch/crates/core_arch/src/mod.rs - core_arch::arch (line 132)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/../../stdarch/crates/core_arch/src/mod.rs - core_arch::arch (line 132)"),
ignore: true,
ignore_message: None,
source_file: "library/core/src/../../stdarch/crates/core_arch/src/mod.rs",
start_line: 132,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_2 {
fn main() {
let mut dst = [0];
add_quickly(&[1], &[2], &mut dst);
assert_eq!(dst[0], 3);
}
fn add_quickly(a: &[u8], b: &[u8], c: &mut [u8]) {
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
{
// Note that this `unsafe` block is safe because we're testing
// that the `avx2` feature is indeed available on our CPU.
if is_x86_feature_detected!("avx2") {
return unsafe { add_quickly_avx2(a, b, c) };
}
}
add_quickly_fallback(a, b, c)
}
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[target_feature(enable = "avx2")]
unsafe fn add_quickly_avx2(a: &[u8], b: &[u8], c: &mut [u8]) {
add_quickly_fallback(a, b, c) // the function below is inlined here
}
fn add_quickly_fallback(a: &[u8], b: &[u8], c: &mut [u8]) {
for ((a, b), c) in a.iter().zip(b).zip(c) {
*c = *a + *b;
}
}
#[rustc_test_marker = "library/core/src/../../stdarch/crates/core_arch/src/mod.rs - core_arch::arch (line 234)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/../../stdarch/crates/core_arch/src/mod.rs - core_arch::arch (line 234)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/../../stdarch/crates/core_arch/src/mod.rs",
start_line: 234,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_3 {
fn main() {
let mut dst = [0; 32];
hex_encode(b"\x01\x02\x03", &mut dst);
assert_eq!(&dst[..6], b"010203");
let mut src = [0; 16];
for i in 0..16 {
src[i] = (i + 1) as u8;
}
hex_encode(&src, &mut dst);
assert_eq!(&dst, b"0102030405060708090a0b0c0d0e0f10");
}
pub fn hex_encode(src: &[u8], dst: &mut [u8]) {
let len = src.len().checked_mul(2).unwrap();
assert!(dst.len() >= len);
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
{
if is_x86_feature_detected!("sse4.1") {
return unsafe { hex_encode_sse41(src, dst) };
}
}
hex_encode_fallback(src, dst)
}
// translated from
// <https://github.com/Matherunner/bin2hex-sse/blob/master/base16_sse4.cpp>
#[target_feature(enable = "sse4.1")]
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
unsafe fn hex_encode_sse41(mut src: &[u8], dst: &mut [u8]) {
#[cfg(target_arch = "x86")]
use std::arch::x86::*;
#[cfg(target_arch = "x86_64")]
use std::arch::x86_64::*;
let ascii_zero = _mm_set1_epi8(b'0' as i8);
let nines = _mm_set1_epi8(9);
let ascii_a = _mm_set1_epi8((b'a' - 9 - 1) as i8);
let and4bits = _mm_set1_epi8(0xf);
let mut i = 0_isize;
while src.len() >= 16 {
let invec = _mm_loadu_si128(src.as_ptr() as *const _);
let masked1 = _mm_and_si128(invec, and4bits);
let masked2 = _mm_and_si128(_mm_srli_epi64(invec, 4), and4bits);
// return 0xff corresponding to the elements > 9, or 0x00 otherwise
let cmpmask1 = _mm_cmpgt_epi8(masked1, nines);
let cmpmask2 = _mm_cmpgt_epi8(masked2, nines);
// add '0' or the offset depending on the masks
let masked1 = _mm_add_epi8(
masked1,
_mm_blendv_epi8(ascii_zero, ascii_a, cmpmask1),
);
let masked2 = _mm_add_epi8(
masked2,
_mm_blendv_epi8(ascii_zero, ascii_a, cmpmask2),
);
// interleave masked1 and masked2 bytes
let res1 = _mm_unpacklo_epi8(masked2, masked1);
let res2 = _mm_unpackhi_epi8(masked2, masked1);
_mm_storeu_si128(dst.as_mut_ptr().offset(i * 2) as *mut _, res1);
_mm_storeu_si128(
dst.as_mut_ptr().offset(i * 2 + 16) as *mut _,
res2,
);
src = &src[16..];
i += 16;
}
let i = i as usize;
hex_encode_fallback(src, &mut dst[i * 2..]);
}
fn hex_encode_fallback(src: &[u8], dst: &mut [u8]) {
fn hex(byte: u8) -> u8 {
static TABLE: &[u8] = b"0123456789abcdef";
TABLE[byte as usize]
}
for (byte, slots) in src.iter().zip(dst.chunks_mut(2)) {
slots[0] = hex((*byte >> 4) & 0xf);
slots[1] = hex(*byte & 0xf);
}
}
#[rustc_test_marker = "library/core/src/../../stdarch/crates/core_arch/src/mod.rs - core_arch::arch (line 270)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/../../stdarch/crates/core_arch/src/mod.rs - core_arch::arch (line 270)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/../../stdarch/crates/core_arch/src/mod.rs",
start_line: 270,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_4 {
#[rustc_test_marker = "library/core/src/../../stdarch/crates/core_arch/src/mod.rs - core_arch::arch (line 76)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/../../stdarch/crates/core_arch/src/mod.rs - core_arch::arch (line 76)"),
ignore: true,
ignore_message: None,
source_file: "library/core/src/../../stdarch/crates/core_arch/src/mod.rs",
start_line: 76,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_5 {
#[cfg(target_arch = "x86")]
use std::arch::x86::*;
#[cfg(target_arch = "x86_64")]
use std::arch::x86_64::*;
fn main() {
#[target_feature(enable = "sse")]
unsafe fn foo() {
let four_zeros = _mm_setzero_ps();
let four_ones = _mm_set1_ps(1.0);
let four_floats = _mm_set_ps(1.0, 2.0, 3.0, 4.0);
}
if is_x86_feature_detected!("sse") { unsafe { foo() } }
}
#[rustc_test_marker = "library/core/src/../../stdarch/crates/core_arch/src/x86/mod.rs - core_arch::x86::__m128 (line 28)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/../../stdarch/crates/core_arch/src/x86/mod.rs - core_arch::x86::__m128 (line 28)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/../../stdarch/crates/core_arch/src/x86/mod.rs",
start_line: 28,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_6 {
#[cfg(target_arch = "x86")]
use std::arch::x86::*;
#[cfg(target_arch = "x86_64")]
use std::arch::x86_64::*;
fn main() {
#[target_feature(enable = "sse")]
unsafe fn foo() {
let two_zeros = _mm_setzero_pd();
let two_ones = _mm_set1_pd(1.0);
let two_floats = _mm_set_pd(1.0, 2.0);
}
if is_x86_feature_detected!("sse") { unsafe { foo() } }
}
#[rustc_test_marker = "library/core/src/../../stdarch/crates/core_arch/src/x86/mod.rs - core_arch::x86::__m128d (line 28)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/../../stdarch/crates/core_arch/src/x86/mod.rs - core_arch::x86::__m128d (line 28)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/../../stdarch/crates/core_arch/src/x86/mod.rs",
start_line: 28,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_7 {
#[cfg(target_arch = "x86")]
use std::arch::x86::*;
#[cfg(target_arch = "x86_64")]
use std::arch::x86_64::*;
fn main() {
#[target_feature(enable = "sse2")]
unsafe fn foo() {
let all_bytes_zero = _mm_setzero_si128();
let all_bytes_one = _mm_set1_epi8(1);
let four_i32 = _mm_set_epi32(1, 2, 3, 4);
}
if is_x86_feature_detected!("sse2") { unsafe { foo() } }
}
#[rustc_test_marker = "library/core/src/../../stdarch/crates/core_arch/src/x86/mod.rs - core_arch::x86::__m128i (line 35)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/../../stdarch/crates/core_arch/src/x86/mod.rs - core_arch::x86::__m128i (line 35)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/../../stdarch/crates/core_arch/src/x86/mod.rs",
start_line: 35,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_8 {
#[cfg(target_arch = "x86")]
use std::arch::x86::*;
#[cfg(target_arch = "x86_64")]
use std::arch::x86_64::*;
fn main() {
#[target_feature(enable = "avx")]
unsafe fn foo() {
let eight_zeros = _mm256_setzero_ps();
let eight_ones = _mm256_set1_ps(1.0);
let eight_floats = _mm256_set_ps(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0);
}
if is_x86_feature_detected!("avx") { unsafe { foo() } }
}
#[rustc_test_marker = "library/core/src/../../stdarch/crates/core_arch/src/x86/mod.rs - core_arch::x86::__m256 (line 28)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/../../stdarch/crates/core_arch/src/x86/mod.rs - core_arch::x86::__m256 (line 28)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/../../stdarch/crates/core_arch/src/x86/mod.rs",
start_line: 28,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_9 {
#[cfg(target_arch = "x86")]
use std::arch::x86::*;
#[cfg(target_arch = "x86_64")]
use std::arch::x86_64::*;
fn main() {
#[target_feature(enable = "avx")]
unsafe fn foo() {
let four_zeros = _mm256_setzero_pd();
let four_ones = _mm256_set1_pd(1.0);
let four_floats = _mm256_set_pd(1.0, 2.0, 3.0, 4.0);
}
if is_x86_feature_detected!("avx") { unsafe { foo() } }
}
#[rustc_test_marker = "library/core/src/../../stdarch/crates/core_arch/src/x86/mod.rs - core_arch::x86::__m256d (line 28)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/../../stdarch/crates/core_arch/src/x86/mod.rs - core_arch::x86::__m256d (line 28)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/../../stdarch/crates/core_arch/src/x86/mod.rs",
start_line: 28,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_10 {
#[cfg(target_arch = "x86")]
use std::arch::x86::*;
#[cfg(target_arch = "x86_64")]
use std::arch::x86_64::*;
fn main() {
#[target_feature(enable = "avx")]
unsafe fn foo() {
let all_bytes_zero = _mm256_setzero_si256();
let all_bytes_one = _mm256_set1_epi8(1);
let eight_i32 = _mm256_set_epi32(1, 2, 3, 4, 5, 6, 7, 8);
}
if is_x86_feature_detected!("avx") { unsafe { foo() } }
}
#[rustc_test_marker = "library/core/src/../../stdarch/crates/core_arch/src/x86/mod.rs - core_arch::x86::__m256i (line 32)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/../../stdarch/crates/core_arch/src/x86/mod.rs - core_arch::x86::__m256i (line 32)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/../../stdarch/crates/core_arch/src/x86/mod.rs",
start_line: 32,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_11 {
#[rustc_test_marker = "library/core/src/../../stdarch/crates/core_arch/src/x86/sse.rs - core_arch::x86::sse::_mm_setcsr (line 1518)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/../../stdarch/crates/core_arch/src/x86/sse.rs - core_arch::x86::sse::_mm_setcsr (line 1518)"),
ignore: true,
ignore_message: None,
source_file: "library/core/src/../../stdarch/crates/core_arch/src/x86/sse.rs",
start_line: 1518,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_12 {
#[rustc_test_marker = "library/core/src/../../stdarch/crates/core_arch/src/x86/sse.rs - core_arch::x86::sse::_mm_setcsr (line 1534)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/../../stdarch/crates/core_arch/src/x86/sse.rs - core_arch::x86::sse::_mm_setcsr (line 1534)"),
ignore: true,
ignore_message: None,
source_file: "library/core/src/../../stdarch/crates/core_arch/src/x86/sse.rs",
start_line: 1534,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_13 {
#[rustc_test_marker = "library/core/src/../../stdarch/crates/core_arch/src/x86/sse.rs - core_arch::x86::sse::_mm_setcsr (line 1542)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/../../stdarch/crates/core_arch/src/x86/sse.rs - core_arch::x86::sse::_mm_setcsr (line 1542)"),
ignore: true,
ignore_message: None,
source_file: "library/core/src/../../stdarch/crates/core_arch/src/x86/sse.rs",
start_line: 1542,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_14 {
#[rustc_test_marker = "library/core/src/../../stdarch/crates/core_arch/src/x86/sse.rs - core_arch::x86::sse::_mm_setcsr (line 1573)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/../../stdarch/crates/core_arch/src/x86/sse.rs - core_arch::x86::sse::_mm_setcsr (line 1573)"),
ignore: true,
ignore_message: None,
source_file: "library/core/src/../../stdarch/crates/core_arch/src/x86/sse.rs",
start_line: 1573,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_15 {
#[rustc_test_marker = "library/core/src/../../stdarch/crates/core_arch/src/x86/sse.rs - core_arch::x86::sse::_mm_setcsr (line 1585)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/../../stdarch/crates/core_arch/src/x86/sse.rs - core_arch::x86::sse::_mm_setcsr (line 1585)"),
ignore: true,
ignore_message: None,
source_file: "library/core/src/../../stdarch/crates/core_arch/src/x86/sse.rs",
start_line: 1585,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_16 {
#[rustc_test_marker = "library/core/src/alloc/global.rs - alloc::global::GlobalAlloc (line 107)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/alloc/global.rs - alloc::global::GlobalAlloc (line 107)"),
ignore: true,
ignore_message: None,
source_file: "library/core/src/alloc/global.rs",
start_line: 107,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_17 {
use std::alloc::{GlobalAlloc, Layout};
use std::cell::UnsafeCell;
use std::ptr::null_mut;
use std::sync::atomic::{AtomicUsize, Ordering::Relaxed};
const ARENA_SIZE: usize = 128 * 1024;
const MAX_SUPPORTED_ALIGN: usize = 4096;
#[repr(C, align(4096))] // 4096 == MAX_SUPPORTED_ALIGN
struct SimpleAllocator {
arena: UnsafeCell<[u8; ARENA_SIZE]>,
remaining: AtomicUsize, // we allocate from the top, counting down
}
#[global_allocator]
static ALLOCATOR: SimpleAllocator = SimpleAllocator {
arena: UnsafeCell::new([0x55; ARENA_SIZE]),
remaining: AtomicUsize::new(ARENA_SIZE),
};
unsafe impl Sync for SimpleAllocator {}
unsafe impl GlobalAlloc for SimpleAllocator {
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
let size = layout.size();
let align = layout.align();
// `Layout` contract forbids making a `Layout` with align=0, or align not power of 2.
// So we can safely use a mask to ensure alignment without worrying about UB.
let align_mask_to_round_down = !(align - 1);
if align > MAX_SUPPORTED_ALIGN {
return null_mut();
}
let mut allocated = 0;
if self
.remaining
.fetch_update(Relaxed, Relaxed, |mut remaining| {
if size > remaining {
return None;
}
remaining -= size;
remaining &= align_mask_to_round_down;
allocated = remaining;
Some(remaining)
})
.is_err()
{
return null_mut();
};
self.arena.get().cast::<u8>().add(allocated)
}
unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {}
}
fn main() {
let _s = format!("allocating a string!");
let currently = ALLOCATOR.remaining.load(Relaxed);
println!("allocated so far: {}", ARENA_SIZE - currently);
}
#[rustc_test_marker = "library/core/src/alloc/global.rs - alloc::global::GlobalAlloc (line 23)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/alloc/global.rs - alloc::global::GlobalAlloc (line 23)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/alloc/global.rs",
start_line: 23,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_18 {
fn main() {
use std::alloc::{Layout, LayoutError};
pub fn repr_c(fields: &[Layout]) -> Result<(Layout, Vec<usize>), LayoutError> {
let mut offsets = Vec::new();
let mut layout = Layout::from_size_align(0, 1)?;
for &field in fields {
let (new_layout, offset) = layout.extend(field)?;
layout = new_layout;
offsets.push(offset);
}
// Remember to finalize with `pad_to_align`!
Ok((layout.pad_to_align(), offsets))
}
// test that it works
#[repr(C)] struct S { a: u64, b: u32, c: u16, d: u32 }
let s = Layout::new::<S>();
let u16 = Layout::new::<u16>();
let u32 = Layout::new::<u32>();
let u64 = Layout::new::<u64>();
assert_eq!(repr_c(&[u64, u32, u16, u32]), Ok((s, vec![0, 8, 12, 16])));
}
#[rustc_test_marker = "library/core/src/alloc/layout.rs - alloc::layout::Layout::extend (line 359)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/alloc/layout.rs - alloc::layout::Layout::extend (line 359)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/alloc/layout.rs",
start_line: 359,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_19 {
fn main() {
use std::any::{Any, TypeId};
let boxed: Box<dyn Any> = Box::new(3_i32);
// You're more likely to want this:
let actual_id = (&*boxed).type_id();
// ... than this:
let boxed_id = boxed.type_id();
assert_eq!(actual_id, TypeId::of::<i32>());
assert_eq!(boxed_id, TypeId::of::<Box<dyn Any>>());
}
#[rustc_test_marker = "library/core/src/any.rs - any (line 27)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/any.rs - any (line 27)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/any.rs",
start_line: 27,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_20 {
use std::fmt::Debug;
use std::any::Any;
// Logger function for any type that implements `Debug`.
fn log<T: Any + Debug>(value: &T) {
let value_any = value as &dyn Any;
// Try to convert our value to a `String`. If successful, we want to
// output the `String`'s length as well as its value. If not, it's a
// different type: just print it out unadorned.
match value_any.downcast_ref::<String>() {
Some(as_string) => {
println!("String ({}): {}", as_string.len(), as_string);
}
None => {
println!("{value:?}");
}
}
}
// This function wants to log its parameter out prior to doing work with it.
fn do_work<T: Any + Debug>(value: &T) {
log(value);
// ...do some other work
}
fn main() {
let my_string = "Hello World".to_string();
do_work(&my_string);
let my_i8: i8 = 100;
do_work(&my_i8);
}
#[rustc_test_marker = "library/core/src/any.rs - any (line 50)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/any.rs - any (line 50)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/any.rs",
start_line: 50,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_21 {
fn main() {
use std::any::{Any, TypeId};
fn is_string(s: &dyn Any) -> bool {
TypeId::of::<String>() == s.type_id()
}
assert_eq!(is_string(&0), false);
assert_eq!(is_string(&"cookie monster".to_string()), true);
}
#[rustc_test_marker = "library/core/src/any.rs - any::Any::type_id (line 125)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/any.rs - any::Any::type_id (line 125)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/any.rs",
start_line: 125,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_22 {
fn main() {
use std::any::{Any, TypeId};
fn is_string<T: ?Sized + Any>(_s: &T) -> bool {
TypeId::of::<String>() == TypeId::of::<T>()
}
assert_eq!(is_string(&0), false);
assert_eq!(is_string(&"cookie monster".to_string()), true);
}
#[rustc_test_marker = "library/core/src/any.rs - any::TypeId::of (line 627)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/any.rs - any::TypeId::of (line 627)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/any.rs",
start_line: 627,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_23 {
fn main() {
use std::any::Any;
fn modify_if_u32(s: &mut (dyn Any + Send + Sync)) {
if let Some(num) = s.downcast_mut::<u32>() {
*num = 42;
}
}
let mut x = 10u32;
let mut s = "starlord".to_string();
modify_if_u32(&mut x);
modify_if_u32(&mut s);
assert_eq!(x, 42);
assert_eq!(&s, "starlord");
}
#[rustc_test_marker = "library/core/src/any.rs - any::dynAny+Send+Sync::downcast_mut (line 518)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/any.rs - any::dynAny+Send+Sync::downcast_mut (line 518)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/any.rs",
start_line: 518,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_24 {
fn main() {
use std::any::Any;
fn print_if_string(s: &(dyn Any + Send + Sync)) {
if let Some(string) = s.downcast_ref::<String>() {
println!("It's a string({}): '{}'", string.len(), string);
} else {
println!("Not a string...");
}
}
print_if_string(&0);
print_if_string(&"cookie monster".to_string());
}
#[rustc_test_marker = "library/core/src/any.rs - any::dynAny+Send+Sync::downcast_ref (line 494)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/any.rs - any::dynAny+Send+Sync::downcast_ref (line 494)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/any.rs",
start_line: 494,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_25 {
fn main() {
use std::any::Any;
fn is_string(s: &(dyn Any + Send + Sync)) {
if s.is::<String>() {
println!("It's a string!");
} else {
println!("Not a string...");
}
}
is_string(&0);
is_string(&"cookie monster".to_string());
}
#[rustc_test_marker = "library/core/src/any.rs - any::dynAny+Send+Sync::is (line 470)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/any.rs - any::dynAny+Send+Sync::is (line 470)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/any.rs",
start_line: 470,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_26 {
fn main() {
use std::any::Any;
fn modify_if_u32(s: &mut (dyn Any + Send)) {
if let Some(num) = s.downcast_mut::<u32>() {
*num = 42;
}
}
let mut x = 10u32;
let mut s = "starlord".to_string();
modify_if_u32(&mut x);
modify_if_u32(&mut s);
assert_eq!(x, 42);
assert_eq!(&s, "starlord");
}
#[rustc_test_marker = "library/core/src/any.rs - any::dynAny+Send::downcast_mut (line 386)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/any.rs - any::dynAny+Send::downcast_mut (line 386)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/any.rs",
start_line: 386,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_27 {
fn main() {
use std::any::Any;
fn print_if_string(s: &(dyn Any + Send)) {
if let Some(string) = s.downcast_ref::<String>() {
println!("It's a string({}): '{}'", string.len(), string);
} else {
println!("Not a string...");
}
}
print_if_string(&0);
print_if_string(&"cookie monster".to_string());
}
#[rustc_test_marker = "library/core/src/any.rs - any::dynAny+Send::downcast_ref (line 362)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/any.rs - any::dynAny+Send::downcast_ref (line 362)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/any.rs",
start_line: 362,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_28 {
fn main() {
use std::any::Any;
fn is_string(s: &(dyn Any + Send)) {
if s.is::<String>() {
println!("It's a string!");
} else {
println!("Not a string...");
}
}
is_string(&0);
is_string(&"cookie monster".to_string());
}
#[rustc_test_marker = "library/core/src/any.rs - any::dynAny+Send::is (line 338)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/any.rs - any::dynAny+Send::is (line 338)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/any.rs",
start_line: 338,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_29 {
fn main() {
use std::any::Any;
fn modify_if_u32(s: &mut dyn Any) {
if let Some(num) = s.downcast_mut::<u32>() {
*num = 42;
}
}
let mut x = 10u32;
let mut s = "starlord".to_string();
modify_if_u32(&mut x);
modify_if_u32(&mut s);
assert_eq!(x, 42);
assert_eq!(&s, "starlord");
}
#[rustc_test_marker = "library/core/src/any.rs - any::dynAny::downcast_mut (line 243)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/any.rs - any::dynAny::downcast_mut (line 243)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/any.rs",
start_line: 243,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_30 {
fn main() {
use std::any::Any;
fn print_if_string(s: &dyn Any) {
if let Some(string) = s.downcast_ref::<String>() {
println!("It's a string({}): '{}'", string.len(), string);
} else {
println!("Not a string...");
}
}
print_if_string(&0);
print_if_string(&"cookie monster".to_string());
}
#[rustc_test_marker = "library/core/src/any.rs - any::dynAny::downcast_ref (line 211)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/any.rs - any::dynAny::downcast_ref (line 211)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/any.rs",
start_line: 211,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_31 {
fn main() {
use std::any::Any;
fn is_string(s: &dyn Any) {
if s.is::<String>() {
println!("It's a string!");
} else {
println!("Not a string...");
}
}
is_string(&0);
is_string(&"cookie monster".to_string());
}
#[rustc_test_marker = "library/core/src/any.rs - any::dynAny::is (line 179)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/any.rs - any::dynAny::is (line 179)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/any.rs",
start_line: 179,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_32 {
fn main() {
assert_eq!(
std::any::type_name::<Option<String>>(),
"core::option::Option<alloc::string::String>",
);
}
#[rustc_test_marker = "library/core/src/any.rs - any::type_name (line 690)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/any.rs - any::type_name (line 690)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/any.rs",
start_line: 690,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_33 {
fn main() {
use std::any::type_name_of_val;
let s = "foo";
let x: i32 = 1;
let y: f32 = 1.0;
assert!(type_name_of_val(&s).contains("str"));
assert!(type_name_of_val(&x).contains("i32"));
assert!(type_name_of_val(&y).contains("f32"));
}
#[rustc_test_marker = "library/core/src/any.rs - any::type_name_of_val (line 725)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/any.rs - any::type_name_of_val (line 725)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/any.rs",
start_line: 725,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_34 {
#[rustc_test_marker = "library/core/src/arch.rs - arch (line 114)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/arch.rs - arch (line 114)"),
ignore: true,
ignore_message: None,
source_file: "library/core/src/arch.rs",
start_line: 114,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_35 {
fn main() {
let mut dst = [0];
add_quickly(&[1], &[2], &mut dst);
assert_eq!(dst[0], 3);
}
fn add_quickly(a: &[u8], b: &[u8], c: &mut [u8]) {
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
{
// Note that this `unsafe` block is safe because we're testing
// that the `avx2` feature is indeed available on our CPU.
if is_x86_feature_detected!("avx2") {
return unsafe { add_quickly_avx2(a, b, c) };
}
}
add_quickly_fallback(a, b, c)
}
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[target_feature(enable = "avx2")]
unsafe fn add_quickly_avx2(a: &[u8], b: &[u8], c: &mut [u8]) {
add_quickly_fallback(a, b, c) // the function below is inlined here
}
fn add_quickly_fallback(a: &[u8], b: &[u8], c: &mut [u8]) {
for ((a, b), c) in a.iter().zip(b).zip(c) {
*c = *a + *b;
}
}
#[rustc_test_marker = "library/core/src/arch.rs - arch (line 216)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/arch.rs - arch (line 216)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/arch.rs",
start_line: 216,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_36 {
fn main() {
let mut dst = [0; 32];
hex_encode(b"\x01\x02\x03", &mut dst);
assert_eq!(&dst[..6], b"010203");
let mut src = [0; 16];
for i in 0..16 {
src[i] = (i + 1) as u8;
}
hex_encode(&src, &mut dst);
assert_eq!(&dst, b"0102030405060708090a0b0c0d0e0f10");
}
pub fn hex_encode(src: &[u8], dst: &mut [u8]) {
let len = src.len().checked_mul(2).unwrap();
assert!(dst.len() >= len);
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
{
if is_x86_feature_detected!("sse4.1") {
return unsafe { hex_encode_sse41(src, dst) };
}
}
hex_encode_fallback(src, dst)
}
// translated from
// <https://github.com/Matherunner/bin2hex-sse/blob/master/base16_sse4.cpp>
#[target_feature(enable = "sse4.1")]
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
unsafe fn hex_encode_sse41(mut src: &[u8], dst: &mut [u8]) {
#[cfg(target_arch = "x86")]
use std::arch::x86::*;
#[cfg(target_arch = "x86_64")]
use std::arch::x86_64::*;
let ascii_zero = _mm_set1_epi8(b'0' as i8);
let nines = _mm_set1_epi8(9);
let ascii_a = _mm_set1_epi8((b'a' - 9 - 1) as i8);
let and4bits = _mm_set1_epi8(0xf);
let mut i = 0_isize;
while src.len() >= 16 {
let invec = _mm_loadu_si128(src.as_ptr() as *const _);
let masked1 = _mm_and_si128(invec, and4bits);
let masked2 = _mm_and_si128(_mm_srli_epi64(invec, 4), and4bits);
// return 0xff corresponding to the elements > 9, or 0x00 otherwise
let cmpmask1 = _mm_cmpgt_epi8(masked1, nines);
let cmpmask2 = _mm_cmpgt_epi8(masked2, nines);
// add '0' or the offset depending on the masks
let masked1 = _mm_add_epi8(
masked1,
_mm_blendv_epi8(ascii_zero, ascii_a, cmpmask1),
);
let masked2 = _mm_add_epi8(
masked2,
_mm_blendv_epi8(ascii_zero, ascii_a, cmpmask2),
);
// interleave masked1 and masked2 bytes
let res1 = _mm_unpacklo_epi8(masked2, masked1);
let res2 = _mm_unpackhi_epi8(masked2, masked1);
_mm_storeu_si128(dst.as_mut_ptr().offset(i * 2) as *mut _, res1);
_mm_storeu_si128(
dst.as_mut_ptr().offset(i * 2 + 16) as *mut _,
res2,
);
src = &src[16..];
i += 16;
}
let i = i as usize;
hex_encode_fallback(src, &mut dst[i * 2..]);
}
fn hex_encode_fallback(src: &[u8], dst: &mut [u8]) {
fn hex(byte: u8) -> u8 {
static TABLE: &[u8] = b"0123456789abcdef";
TABLE[byte as usize]
}
for (byte, slots) in src.iter().zip(dst.chunks_mut(2)) {
slots[0] = hex((*byte >> 4) & 0xf);
slots[1] = hex(*byte & 0xf);
}
}
#[rustc_test_marker = "library/core/src/arch.rs - arch (line 252)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/arch.rs - arch (line 252)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/arch.rs",
start_line: 252,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_37 {
#[rustc_test_marker = "library/core/src/arch.rs - arch (line 58)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/arch.rs - arch (line 58)"),
ignore: true,
ignore_message: None,
source_file: "library/core/src/arch.rs",
start_line: 58,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_38 {
fn main() {
let bytes: [u8; 3] = [1, 0, 2];
let bytes_head: &[u8; 2] = <&[u8; 2]>::try_from(&bytes[0..2]).unwrap();
assert_eq!(1, u16::from_le_bytes(*bytes_head));
let bytes_tail: &[u8; 2] = bytes[1..3].try_into().unwrap();
assert_eq!(512, u16::from_le_bytes(*bytes_tail));
}
#[rustc_test_marker = "library/core/src/array/mod.rs - array::&'a[T;N] (line 241)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/array/mod.rs - array::&'a[T;N] (line 241)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/array/mod.rs",
start_line: 241,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_39 {
fn main() {
let mut bytes: [u8; 3] = [1, 0, 2];
let bytes_head: &mut [u8; 2] = <&mut [u8; 2]>::try_from(&mut bytes[0..2]).unwrap();
assert_eq!(1, u16::from_le_bytes(*bytes_head));
let bytes_tail: &mut [u8; 2] = (&mut bytes[1..3]).try_into().unwrap();
assert_eq!(512, u16::from_le_bytes(*bytes_tail));
}
#[rustc_test_marker = "library/core/src/array/mod.rs - array::&'amut[T;N] (line 269)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/array/mod.rs - array::&'amut[T;N] (line 269)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/array/mod.rs",
start_line: 269,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_40 {
fn main() {
let bytes: [u8; 3] = [1, 0, 2];
let bytes_head: [u8; 2] = <[u8; 2]>::try_from(&bytes[0..2]).unwrap();
assert_eq!(1, u16::from_le_bytes(bytes_head));
let bytes_tail: [u8; 2] = bytes[1..3].try_into().unwrap();
assert_eq!(512, u16::from_le_bytes(bytes_tail));
}
#[rustc_test_marker = "library/core/src/array/mod.rs - array::[T;N] (line 191)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/array/mod.rs - array::[T;N] (line 191)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/array/mod.rs",
start_line: 191,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_41 {
fn main() {
let mut bytes: [u8; 3] = [1, 0, 2];
let bytes_head: [u8; 2] = <[u8; 2]>::try_from(&mut bytes[0..2]).unwrap();
assert_eq!(1, u16::from_le_bytes(bytes_head));
let bytes_tail: [u8; 2] = (&mut bytes[1..3]).try_into().unwrap();
assert_eq!(512, u16::from_le_bytes(bytes_tail));
}
#[rustc_test_marker = "library/core/src/array/mod.rs - array::[T;N] (line 216)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/array/mod.rs - array::[T;N] (line 216)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/array/mod.rs",
start_line: 216,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_42 {
fn main() {
use std::hash::BuildHasher;
let b = std::hash::RandomState::new();
let a: [u8; 3] = [0xa8, 0x3c, 0x09];
let s: &[u8] = &[0xa8, 0x3c, 0x09];
assert_eq!(b.hash_one(a), b.hash_one(s));
}
#[rustc_test_marker = "library/core/src/array/mod.rs - array::[T;N] (line 297)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/array/mod.rs - array::[T;N] (line 297)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/array/mod.rs",
start_line: 297,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_43 {
fn main() {
let mut floats = [3.1, 2.7, -1.0];
let float_refs: [&mut f64; 3] = floats.each_mut();
*float_refs[0] = 0.0;
assert_eq!(float_refs, [&mut 0.0, &mut 2.7, &mut -1.0]);
assert_eq!(floats, [0.0, 2.7, -1.0]);
}
#[rustc_test_marker = "library/core/src/array/mod.rs - array::[T;N]::each_mut (line 594)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/array/mod.rs - array::[T;N]::each_mut (line 594)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/array/mod.rs",
start_line: 594,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_44 {
fn main() {
let floats = [3.1, 2.7, -1.0];
let float_refs: [&f64; 3] = floats.each_ref();
assert_eq!(float_refs, [&3.1, &2.7, &-1.0]);
}
#[rustc_test_marker = "library/core/src/array/mod.rs - array::[T;N]::each_ref (line 565)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/array/mod.rs - array::[T;N]::each_ref (line 565)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/array/mod.rs",
start_line: 565,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_45 {
fn main() {
let strings = ["Ferris".to_string(), "♥".to_string(), "Rust".to_string()];
let is_ascii = strings.each_ref().map(|s| s.is_ascii());
assert_eq!(is_ascii, [true, false, true]);
// We can still access the original array: it has not been moved.
assert_eq!(strings.len(), 3);
}
#[rustc_test_marker = "library/core/src/array/mod.rs - array::[T;N]::each_ref (line 575)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/array/mod.rs - array::[T;N]::each_ref (line 575)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/array/mod.rs",
start_line: 575,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_46 {
fn main() {
let x = [1, 2, 3];
let y = x.map(|v| v + 1);
assert_eq!(y, [2, 3, 4]);
let x = [1, 2, 3];
let mut temp = 0;
let y = x.map(|v| { temp += 1; v * temp });
assert_eq!(y, [1, 4, 9]);
let x = ["Ferris", "Bueller's", "Day", "Off"];
let y = x.map(|v| v.len());
assert_eq!(y, [6, 9, 3, 3]);
}
#[rustc_test_marker = "library/core/src/array/mod.rs - array::[T;N]::map (line 483)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/array/mod.rs - array::[T;N]::map (line 483)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/array/mod.rs",
start_line: 483,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_47 {
fn main() {
let array = core::array::from_fn(|i| i);
// indexes are: 0 1 2 3 4
assert_eq!(array, [0, 1, 2, 3, 4]);
let array2: [usize; 8] = core::array::from_fn(|i| i * 2);
// indexes are: 0 1 2 3 4 5 6 7
assert_eq!(array2, [0, 2, 4, 6, 8, 10, 12, 14]);
let bool_arr = core::array::from_fn::<_, 5, _>(|i| i % 2 == 0);
// indexes are: 0 1 2 3 4
assert_eq!(bool_arr, [true, false, true, false, true]);
}
#[rustc_test_marker = "library/core/src/array/mod.rs - array::from_fn (line 39)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/array/mod.rs - array::from_fn (line 39)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/array/mod.rs",
start_line: 39,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_48 {
fn main() {
use std::ascii;
let escaped = ascii::escape_default(b'0').next().unwrap();
assert_eq!(b'0', escaped);
let mut escaped = ascii::escape_default(b'\t');
assert_eq!(b'\\', escaped.next().unwrap());
assert_eq!(b't', escaped.next().unwrap());
let mut escaped = ascii::escape_default(b'\r');
assert_eq!(b'\\', escaped.next().unwrap());
assert_eq!(b'r', escaped.next().unwrap());
let mut escaped = ascii::escape_default(b'\n');
assert_eq!(b'\\', escaped.next().unwrap());
assert_eq!(b'n', escaped.next().unwrap());
let mut escaped = ascii::escape_default(b'\'');
assert_eq!(b'\\', escaped.next().unwrap());
assert_eq!(b'\'', escaped.next().unwrap());
let mut escaped = ascii::escape_default(b'"');
assert_eq!(b'\\', escaped.next().unwrap());
assert_eq!(b'"', escaped.next().unwrap());
let mut escaped = ascii::escape_default(b'\\');
assert_eq!(b'\\', escaped.next().unwrap());
assert_eq!(b'\\', escaped.next().unwrap());
let mut escaped = ascii::escape_default(b'\x9d');
assert_eq!(b'\\', escaped.next().unwrap());
assert_eq!(b'x', escaped.next().unwrap());
assert_eq!(b'9', escaped.next().unwrap());
assert_eq!(b'd', escaped.next().unwrap());
}
#[rustc_test_marker = "library/core/src/ascii.rs - ascii::escape_default (line 49)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/ascii.rs - ascii::escape_default (line 49)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/ascii.rs",
start_line: 49,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_49 {
fn main() {
use core::task::{Context, Poll};
use core::pin::Pin;
trait AsyncIterator {
type Item;
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>>;
}
}
#[rustc_test_marker = "library/core/src/async_iter/mod.rs - async_iter (line 32)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/async_iter/mod.rs - async_iter (line 32)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/async_iter/mod.rs",
start_line: 32,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_50 {
fn main() {
assert_eq!(false.then(|| 0), None);
assert_eq!(true.then(|| 0), Some(0));
}
#[rustc_test_marker = "library/core/src/bool.rs - bool::bool::then (line 42)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/bool.rs - bool::bool::then (line 42)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/bool.rs",
start_line: 42,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_51 {
fn main() {
let mut a = 0;
true.then(|| { a += 1; });
false.then(|| { a += 1; });
// `a` is incremented once because the closure is evaluated lazily by
// `then`.
assert_eq!(a, 1);
}
#[rustc_test_marker = "library/core/src/bool.rs - bool::bool::then (line 47)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/bool.rs - bool::bool::then (line 47)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/bool.rs",
start_line: 47,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_52 {
fn main() {
assert_eq!(false.then_some(0), None);
assert_eq!(true.then_some(0), Some(0));
}
#[rustc_test_marker = "library/core/src/bool.rs - bool::bool::then_some (line 15)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/bool.rs - bool::bool::then_some (line 15)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/bool.rs",
start_line: 15,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_53 {
fn main() {
let mut a = 0;
let mut function_with_side_effects = || { a += 1; };
true.then_some(function_with_side_effects());
false.then_some(function_with_side_effects());
// `a` is incremented twice because the value passed to `then_some` is
// evaluated eagerly.
assert_eq!(a, 2);
}
#[rustc_test_marker = "library/core/src/bool.rs - bool::bool::then_some (line 20)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/bool.rs - bool::bool::then_some (line 20)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/bool.rs",
start_line: 20,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_54 {
fn main() {
pub struct CaseInsensitiveString(String);
impl PartialEq for CaseInsensitiveString {
fn eq(&self, other: &Self) -> bool {
self.0.eq_ignore_ascii_case(&other.0)
}
}
impl Eq for CaseInsensitiveString { }
}
#[rustc_test_marker = "library/core/src/borrow.rs - borrow::Borrow (line 118)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/borrow.rs - borrow::Borrow (line 118)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/borrow.rs",
start_line: 118,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_55 {
fn main() {
use std::hash::{Hash, Hasher};
pub struct CaseInsensitiveString(String);
impl Hash for CaseInsensitiveString {
fn hash<H: Hasher>(&self, state: &mut H) {
for c in self.0.as_bytes() {
c.to_ascii_lowercase().hash(state)
}
}
}
}
#[rustc_test_marker = "library/core/src/borrow.rs - borrow::Borrow (line 133)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/borrow.rs - borrow::Borrow (line 133)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/borrow.rs",
start_line: 133,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_56 {
fn main() {
use std::borrow::Borrow;
use std::hash::Hash;
pub struct HashMap<K, V> {
marker: ::std::marker::PhantomData<(K, V)>,
// fields omitted
}
impl<K, V> HashMap<K, V> {
pub fn insert(&self, key: K, value: V) -> Option<V>
where K: Hash + Eq
{
unimplemented!()
// ...
}
pub fn get<Q>(&self, k: &Q) -> Option<&V>
where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized
{
unimplemented!()
// ...
}
}
}
#[rustc_test_marker = "library/core/src/borrow.rs - borrow::Borrow (line 62)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/borrow.rs - borrow::Borrow (line 62)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/borrow.rs",
start_line: 62,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_57 {
fn main() {
use std::borrow::Borrow;
fn check<T: Borrow<str>>(s: T) {
assert_eq!("Hello", s.borrow());
}
let s = "Hello".to_string();
check(s);
let s = "Hello";
check(s);
}
#[rustc_test_marker = "library/core/src/borrow.rs - borrow::Borrow::borrow (line 162)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/borrow.rs - borrow::Borrow::borrow (line 162)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/borrow.rs",
start_line: 162,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_58 {
fn main() {
use std::borrow::BorrowMut;
fn check<T: BorrowMut<[i32]>>(mut v: T) {
assert_eq!(&mut [1, 2, 3], v.borrow_mut());
}
let v = vec![1, 2, 3];
check(v);
}
#[rustc_test_marker = "library/core/src/borrow.rs - borrow::BorrowMut::borrow_mut (line 192)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/borrow.rs - borrow::BorrowMut::borrow_mut (line 192)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/borrow.rs",
start_line: 192,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_59 {
use std::cell::{RefCell, RefMut};
use std::collections::HashMap;
use std::rc::Rc;
fn main() {
let shared_map: Rc<RefCell<_>> = Rc::new(RefCell::new(HashMap::new()));
// Create a new block to limit the scope of the dynamic borrow
{
let mut map: RefMut<'_, _> = shared_map.borrow_mut();
map.insert("africa", 92388);
map.insert("kyoto", 11837);
map.insert("piccadilly", 11826);
map.insert("marbles", 38);
}
// Note that if we had not let the previous borrow of the cache fall out
// of scope then the subsequent borrow would cause a dynamic thread panic.
// This is the major hazard of using `RefCell`.
let total: i32 = shared_map.borrow().values().sum();
println!("{total}");
}
#[rustc_test_marker = "library/core/src/cell.rs - cell (line 123)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell (line 123)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 123,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_60 {
fn main() {
#![allow(dead_code)]
use std::cell::OnceCell;
struct Graph {
edges: Vec<(i32, i32)>,
span_tree_cache: OnceCell<Vec<(i32, i32)>>
}
impl Graph {
fn minimum_spanning_tree(&self) -> Vec<(i32, i32)> {
self.span_tree_cache
.get_or_init(|| self.calc_span_tree())
.clone()
}
fn calc_span_tree(&self) -> Vec<(i32, i32)> {
// Expensive computation goes here
vec![]
}
}
}
#[rustc_test_marker = "library/core/src/cell.rs - cell (line 158)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell (line 158)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 158,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_61 {
fn main() {
use std::cell::Cell;
use std::ptr::NonNull;
use std::process::abort;
use std::marker::PhantomData;
struct Rc<T: ?Sized> {
ptr: NonNull<RcBox<T>>,
phantom: PhantomData<RcBox<T>>,
}
struct RcBox<T: ?Sized> {
strong: Cell<usize>,
refcount: Cell<usize>,
value: T,
}
impl<T: ?Sized> Clone for Rc<T> {
fn clone(&self) -> Rc<T> {
self.inc_strong();
Rc {
ptr: self.ptr,
phantom: PhantomData,
}
}
}
trait RcBoxPtr<T: ?Sized> {
fn inner(&self) -> &RcBox<T>;
fn strong(&self) -> usize {
self.inner().strong.get()
}
fn inc_strong(&self) {
self.inner()
.strong
.set(self.strong()
.checked_add(1)
.unwrap_or_else(|| abort() ));
}
}
impl<T: ?Sized> RcBoxPtr<T> for Rc<T> {
fn inner(&self) -> &RcBox<T> {
unsafe {
self.ptr.as_ref()
}
}
}
}
#[rustc_test_marker = "library/core/src/cell.rs - cell (line 189)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell (line 189)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 189,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_62 {
fn main() {
use std::cell::Cell;
struct SomeStruct {
regular_field: u8,
special_field: Cell<u8>,
}
let my_struct = SomeStruct {
regular_field: 0,
special_field: Cell::new(1),
};
let new_value = 100;
// ERROR: `my_struct` is immutable
// my_struct.regular_field = new_value;
// WORKS: although `my_struct` is immutable, `special_field` is a `Cell`,
// which can always be mutated
my_struct.special_field.set(new_value);
assert_eq!(my_struct.special_field.get(), new_value);
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::Cell (line 281)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::Cell (line 281)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 281,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_63 {
fn main() {
use std::cell::Cell;
let c = Cell::new(5);
let ptr = c.as_ptr();
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::Cell<T>::as_ptr (line 572)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::Cell<T>::as_ptr (line 572)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 572,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_64 {
fn main() {
use std::cell::Cell;
let slice: &mut [i32] = &mut [1, 2, 3];
let cell_slice: &Cell<[i32]> = Cell::from_mut(slice);
let slice_cell: &[Cell<i32>] = cell_slice.as_slice_of_cells();
assert_eq!(slice_cell.len(), 3);
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::Cell<T>::from_mut (line 619)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::Cell<T>::from_mut (line 619)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 619,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_65 {
fn main() {
use std::cell::Cell;
let c = Cell::new(5);
let five = c.get();
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::Cell<T>::get (line 524)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::Cell<T>::get (line 524)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 524,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_66 {
fn main() {
use std::cell::Cell;
let mut c = Cell::new(5);
*c.get_mut() += 1;
assert_eq!(c.get(), 6);
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::Cell<T>::get_mut (line 601)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::Cell<T>::get_mut (line 601)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 601,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_67 {
fn main() {
use std::cell::Cell;
let c = Cell::new(5);
let five = c.into_inner();
assert_eq!(five, 5);
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::Cell<T>::into_inner (line 504)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::Cell<T>::into_inner (line 504)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 504,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_68 {
fn main() {
use std::cell::Cell;
let c = Cell::new(5);
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::Cell<T>::new (line 400)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::Cell<T>::new (line 400)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 400,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_69 {
fn main() {
use std::cell::Cell;
let cell = Cell::new(5);
assert_eq!(cell.get(), 5);
assert_eq!(cell.replace(10), 5);
assert_eq!(cell.get(), 10);
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::Cell<T>::replace (line 483)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::Cell<T>::replace (line 483)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 483,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_70 {
fn main() {
use std::cell::Cell;
let c = Cell::new(5);
c.set(10);
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::Cell<T>::set (line 416)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::Cell<T>::set (line 416)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 416,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_71 {
fn main() {
use std::cell::Cell;
let c1 = Cell::new(5i32);
let c2 = Cell::new(10i32);
c1.swap(&c2);
assert_eq!(10, c1.get());
assert_eq!(5, c2.get());
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::Cell<T>::swap (line 440)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::Cell<T>::swap (line 440)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 440,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_72 {
fn main() {
use std::cell::Cell;
let c = Cell::new(5);
let five = c.take();
assert_eq!(five, 5);
assert_eq!(c.into_inner(), 0);
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::Cell<T>::take (line 641)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::Cell<T>::take (line 641)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 641,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_73 {
fn main() {
use std::cell::Cell;
let slice: &mut [i32] = &mut [1, 2, 3];
let cell_slice: &Cell<[i32]> = Cell::from_mut(slice);
let slice_cell: &[Cell<i32>] = cell_slice.as_slice_of_cells();
assert_eq!(slice_cell.len(), 3);
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::Cell<[T]>::as_slice_of_cells (line 674)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::Cell<[T]>::as_slice_of_cells (line 674)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 674,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_74 {
fn main() {
use std::cell::{RefCell, Ref};
let c = RefCell::new(vec![1, 2, 3]);
let b1: Ref<'_, Vec<u32>> = c.borrow();
let b2: Result<Ref<'_, u32>, _> = Ref::filter_map(b1, |v| v.get(1));
assert_eq!(*b2.unwrap(), 2);
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::Ref<'b,T>::filter_map (line 1528)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::Ref<'b,T>::filter_map (line 1528)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 1528,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_75 {
fn main() {
use std::cell::{RefCell, Ref};
let c = RefCell::new((5, 'b'));
let b1: Ref<'_, (u32, char)> = c.borrow();
let b2: Ref<'_, u32> = Ref::map(b1, |t| &t.0);
assert_eq!(*b2, 5)
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::Ref<'b,T>::map (line 1499)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::Ref<'b,T>::map (line 1499)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 1499,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_76 {
fn main() {
use std::cell::{Ref, RefCell};
let cell = RefCell::new([1, 2, 3, 4]);
let borrow = cell.borrow();
let (begin, end) = Ref::map_split(borrow, |slice| slice.split_at(2));
assert_eq!(*begin, [1, 2]);
assert_eq!(*end, [3, 4]);
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::Ref<'b,T>::map_split (line 1559)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::Ref<'b,T>::map_split (line 1559)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 1559,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_77 {
fn main() {
use std::cell::RefCell;
let c = RefCell::new(5);
let ptr = c.as_ptr();
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::RefCell<T>::as_ptr (line 1130)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::RefCell<T>::as_ptr (line 1130)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 1130,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_78 {
fn main() {
use std::cell::RefCell;
let c = RefCell::new(5);
let borrowed_five = c.borrow();
let borrowed_five2 = c.borrow();
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::RefCell<T>::borrow (line 955)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::RefCell<T>::borrow (line 955)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 955,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_79 {
fn main() {
use std::cell::RefCell;
let c = RefCell::new(5);
let m = c.borrow_mut();
let b = c.borrow(); // this causes a panic
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::RefCell<T>::borrow (line 966)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::RefCell<T>::borrow (line 966)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 966,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::Yes,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_80 {
fn main() {
use std::cell::RefCell;
let c = RefCell::new("hello".to_owned());
*c.borrow_mut() = "bonjour".to_owned();
assert_eq!(&*c.borrow(), "bonjour");
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::RefCell<T>::borrow_mut (line 1050)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::RefCell<T>::borrow_mut (line 1050)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 1050,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_81 {
fn main() {
use std::cell::RefCell;
let c = RefCell::new(5);
let m = c.borrow();
let b = c.borrow_mut(); // this causes a panic
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::RefCell<T>::borrow_mut (line 1062)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::RefCell<T>::borrow_mut (line 1062)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 1062,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::Yes,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_82 {
fn main() {
use std::cell::RefCell;
let mut c = RefCell::new(5);
*c.get_mut() += 1;
assert_eq!(c, RefCell::new(6));
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::RefCell<T>::get_mut (line 1163)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::RefCell<T>::get_mut (line 1163)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 1163,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_83 {
fn main() {
use std::cell::RefCell;
let c = RefCell::new(5);
let five = c.into_inner();
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::RefCell<T>::into_inner (line 848)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::RefCell<T>::into_inner (line 848)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 848,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_84 {
fn main() {
use std::cell::RefCell;
let c = RefCell::new(5);
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::RefCell<T>::new (line 827)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::RefCell<T>::new (line 827)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 827,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_85 {
fn main() {
use std::cell::RefCell;
let cell = RefCell::new(5);
let old_value = cell.replace(6);
assert_eq!(old_value, 5);
assert_eq!(cell, RefCell::new(6));
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::RefCell<T>::replace (line 875)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::RefCell<T>::replace (line 875)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 875,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_86 {
fn main() {
use std::cell::RefCell;
let cell = RefCell::new(5);
let old_value = cell.replace_with(|&mut old| old + 1);
assert_eq!(old_value, 5);
assert_eq!(cell, RefCell::new(6));
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::RefCell<T>::replace_with (line 899)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::RefCell<T>::replace_with (line 899)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 899,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_87 {
fn main() {
use std::cell::RefCell;
let c = RefCell::new(5);
let d = RefCell::new(6);
c.swap(&d);
assert_eq!(c, RefCell::new(6));
assert_eq!(d, RefCell::new(5));
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::RefCell<T>::swap (line 927)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::RefCell<T>::swap (line 927)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 927,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_88 {
fn main() {
use std::cell::RefCell;
let c = RefCell::new(5);
let five = c.take();
assert_eq!(five, 5);
assert_eq!(c.into_inner(), 0);
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::RefCell<T>::take (line 1261)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::RefCell<T>::take (line 1261)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 1261,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_89 {
fn main() {
use std::cell::RefCell;
let c = RefCell::new(5);
{
let m = c.borrow_mut();
assert!(c.try_borrow().is_err());
}
{
let m = c.borrow();
assert!(c.try_borrow().is_ok());
}
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::RefCell<T>::try_borrow (line 994)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::RefCell<T>::try_borrow (line 994)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 994,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_90 {
fn main() {
use std::cell::RefCell;
let c = RefCell::new(5);
{
let m = c.borrow();
assert!(c.try_borrow_mut().is_err());
}
assert!(c.try_borrow_mut().is_ok());
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::RefCell<T>::try_borrow_mut (line 1090)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::RefCell<T>::try_borrow_mut (line 1090)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 1090,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_91 {
fn main() {
use std::cell::RefCell;
let c = RefCell::new(5);
{
let m = c.borrow_mut();
assert!(unsafe { c.try_borrow_unguarded() }.is_err());
}
{
let m = c.borrow();
assert!(unsafe { c.try_borrow_unguarded() }.is_ok());
}
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::RefCell<T>::try_borrow_unguarded (line 1216)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::RefCell<T>::try_borrow_unguarded (line 1216)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 1216,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_92 {
fn main() {
use std::cell::{RefCell, RefMut};
let c = RefCell::new(vec![1, 2, 3]);
{
let b1: RefMut<'_, Vec<u32>> = c.borrow_mut();
let mut b2: Result<RefMut<'_, u32>, _> = RefMut::filter_map(b1, |v| v.get_mut(1));
if let Ok(mut b2) = b2 {
*b2 += 2;
}
}
assert_eq!(*c.borrow(), vec![1, 4, 3]);
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::RefMut<'b,T>::filter_map (line 1674)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::RefMut<'b,T>::filter_map (line 1674)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 1674,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_93 {
fn main() {
use std::cell::{RefCell, RefMut};
let c = RefCell::new((5, 'b'));
{
let b1: RefMut<'_, (u32, char)> = c.borrow_mut();
let mut b2: RefMut<'_, u32> = RefMut::map(b1, |t| &mut t.0);
assert_eq!(*b2, 5);
*b2 = 42;
}
assert_eq!(*c.borrow(), (42, 'b'));
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::RefMut<'b,T>::map (line 1640)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::RefMut<'b,T>::map (line 1640)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 1640,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_94 {
fn main() {
use std::cell::{RefCell, RefMut};
let cell = RefCell::new([1, 2, 3, 4]);
let borrow = cell.borrow_mut();
let (mut begin, mut end) = RefMut::map_split(borrow, |slice| slice.split_at_mut(2));
assert_eq!(*begin, [1, 2]);
assert_eq!(*end, [3, 4]);
begin.copy_from_slice(&[4, 3]);
end.copy_from_slice(&[2, 1]);
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::RefMut<'b,T>::map_split (line 1722)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::RefMut<'b,T>::map_split (line 1722)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 1722,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_95 {
fn main() {
use std::cell::UnsafeCell;
// Safety: the caller must ensure that there are no references that
// point to the *contents* of the `UnsafeCell`.
unsafe fn get_mut<T>(ptr: &UnsafeCell<T>) -> &mut T {
unsafe { &mut *ptr.get() }
}
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::UnsafeCell (line 1977)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::UnsafeCell (line 1977)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 1977,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_96 {
fn main() {
use std::cell::UnsafeCell;
fn get_shared<T>(ptr: &mut T) -> &UnsafeCell<T> {
let t = ptr as *mut T as *const UnsafeCell<T>;
// SAFETY: `T` and `UnsafeCell<T>` have the same memory layout
unsafe { &*t }
}
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::UnsafeCell (line 1989)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::UnsafeCell (line 1989)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 1989,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_97 {
fn main() {
use std::cell::UnsafeCell;
let x: UnsafeCell<i32> = 42.into();
// Get multiple / concurrent / shared references to the same `x`.
let (p1, p2): (&UnsafeCell<i32>, &UnsafeCell<i32>) = (&x, &x);
unsafe {
// SAFETY: within this scope there are no other references to `x`'s contents,
// so ours is effectively unique.
let p1_exclusive: &mut i32 = &mut *p1.get(); // -- borrow --+
*p1_exclusive += 27; // |
} // <---------- cannot go beyond this point -------------------+
unsafe {
// SAFETY: within this scope nobody expects to have exclusive access to `x`'s contents,
// so we can have multiple shared accesses concurrently.
let p2_shared: &i32 = &*p2.get();
assert_eq!(*p2_shared, 42 + 27);
let p1_shared: &i32 = &*p1.get();
assert_eq!(*p1_shared, *p2_shared);
}
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::UnsafeCell (line 2006)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::UnsafeCell (line 2006)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 2006,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_98 {
fn main() {
#![forbid(unsafe_code)] // with exclusive accesses,
use std::cell::UnsafeCell;
let mut x: UnsafeCell<i32> = 42.into();
// Get a compile-time-checked unique reference to `x`.
let p_unique: &mut UnsafeCell<i32> = &mut x;
// With an exclusive reference, we can mutate the contents for free.
*p_unique.get_mut() = 0;
// Or, equivalently:
x = UnsafeCell::new(0);
// When we own the value, we can extract the contents for free.
let contents: i32 = x.into_inner();
assert_eq!(contents, 0);
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::UnsafeCell (line 2033)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::UnsafeCell (line 2033)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 2033,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_99 {
fn main() {
use std::cell::UnsafeCell;
let uc = UnsafeCell::new(5);
let five = uc.get();
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::UnsafeCell<T>::get (line 2133)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::UnsafeCell<T>::get (line 2133)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 2133,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_100 {
fn main() {
use std::cell::UnsafeCell;
let mut c = UnsafeCell::new(5);
*c.get_mut() += 1;
assert_eq!(*c.get_mut(), 6);
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::UnsafeCell<T>::get_mut (line 2158)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::UnsafeCell<T>::get_mut (line 2158)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 2158,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_101 {
fn main() {
use std::cell::UnsafeCell;
let uc = UnsafeCell::new(5);
let five = uc.into_inner();
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::UnsafeCell<T>::into_inner (line 2086)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::UnsafeCell<T>::into_inner (line 2086)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 2086,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_102 {
fn main() {
use std::cell::UnsafeCell;
let uc = UnsafeCell::new(5);
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::UnsafeCell<T>::new (line 2070)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::UnsafeCell<T>::new (line 2070)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 2070,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_103 {
fn main() {
use std::cell::UnsafeCell;
use std::mem::MaybeUninit;
let m = MaybeUninit::<UnsafeCell<i32>>::uninit();
unsafe { UnsafeCell::raw_get(m.as_ptr()).write(5); }
// avoid below which references to uninitialized data
// unsafe { UnsafeCell::get(&*m.as_ptr()).write(5); }
let uc = unsafe { m.assume_init() };
assert_eq!(uc.into_inner(), 5);
}
#[rustc_test_marker = "library/core/src/cell.rs - cell::UnsafeCell<T>::raw_get (line 2189)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell.rs - cell::UnsafeCell<T>::raw_get (line 2189)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell.rs",
start_line: 2189,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_104 {
fn main() {
use std::cell::LazyCell;
let lazy: LazyCell<i32> = LazyCell::new(|| {
println!("initializing");
92
});
println!("ready");
println!("{}", *lazy);
println!("{}", *lazy);
// Prints:
// ready
// initializing
// 92
// 92
}
#[rustc_test_marker = "library/core/src/cell/lazy.rs - cell::lazy::LazyCell (line 20)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell/lazy.rs - cell::lazy::LazyCell (line 20)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell/lazy.rs",
start_line: 20,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_105 {
fn main() {
use std::cell::LazyCell;
let lazy = LazyCell::new(|| 92);
assert_eq!(LazyCell::force(&lazy), &92);
assert_eq!(&*lazy, &92);
}
#[rustc_test_marker = "library/core/src/cell/lazy.rs - cell::lazy::LazyCell<T,F>::force (line 97)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell/lazy.rs - cell::lazy::LazyCell<T,F>::force (line 97)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell/lazy.rs",
start_line: 97,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_106 {
fn main() {
use std::cell::LazyCell;
let hello = "Hello, World!".to_string();
let lazy = LazyCell::new(|| hello.to_uppercase());
assert_eq!(&*lazy, "HELLO, WORLD!");
}
#[rustc_test_marker = "library/core/src/cell/lazy.rs - cell::lazy::LazyCell<T,F>::new (line 47)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell/lazy.rs - cell::lazy::LazyCell<T,F>::new (line 47)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell/lazy.rs",
start_line: 47,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_107 {
fn main() {
use std::cell::OnceCell;
let cell = OnceCell::new();
assert!(cell.get().is_none());
let value: &String = cell.get_or_init(|| {
"Hello, World!".to_string()
});
assert_eq!(value, "Hello, World!");
assert!(cell.get().is_some());
}
#[rustc_test_marker = "library/core/src/cell/once.rs - cell::once::OnceCell (line 20)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell/once.rs - cell::once::OnceCell (line 20)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell/once.rs",
start_line: 20,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_108 {
fn main() {
use std::cell::OnceCell;
let cell = OnceCell::new();
let value = cell.get_or_init(|| 92);
assert_eq!(value, &92);
let value = cell.get_or_init(|| unreachable!());
assert_eq!(value, &92);
}
#[rustc_test_marker = "library/core/src/cell/once.rs - cell::once::OnceCell<T>::get_or_init (line 147)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell/once.rs - cell::once::OnceCell<T>::get_or_init (line 147)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell/once.rs",
start_line: 147,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_109 {
fn main() {
use std::cell::OnceCell;
let cell: OnceCell<String> = OnceCell::new();
assert_eq!(cell.into_inner(), None);
let cell = OnceCell::new();
cell.set("hello".to_string()).unwrap();
assert_eq!(cell.into_inner(), Some("hello".to_string()));
}
#[rustc_test_marker = "library/core/src/cell/once.rs - cell::once::OnceCell<T>::into_inner (line 301)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell/once.rs - cell::once::OnceCell<T>::into_inner (line 301)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell/once.rs",
start_line: 301,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_110 {
fn main() {
use std::cell::OnceCell;
let cell = OnceCell::new();
assert!(cell.get().is_none());
assert_eq!(cell.set(92), Ok(()));
assert_eq!(cell.set(62), Err(62));
assert!(cell.get().is_some());
}
#[rustc_test_marker = "library/core/src/cell/once.rs - cell::once::OnceCell<T>::set (line 76)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell/once.rs - cell::once::OnceCell<T>::set (line 76)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell/once.rs",
start_line: 76,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_111 {
fn main() {
use std::cell::OnceCell;
let mut cell: OnceCell<String> = OnceCell::new();
assert_eq!(cell.take(), None);
let mut cell = OnceCell::new();
cell.set("hello".to_string()).unwrap();
assert_eq!(cell.take(), Some("hello".to_string()));
assert_eq!(cell.get(), None);
}
#[rustc_test_marker = "library/core/src/cell/once.rs - cell::once::OnceCell<T>::take (line 327)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cell/once.rs - cell::once::OnceCell<T>::take (line 327)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cell/once.rs",
start_line: 327,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_112 {
fn main() {
use std::mem;
let u = 32 as u8;
let c = char::from(u);
assert!(4 == mem::size_of_val(&c))
}
#[rustc_test_marker = "library/core/src/char/convert.rs - char::convert::char::from (line 169)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/convert.rs - char::convert::char::from (line 169)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/convert.rs",
start_line: 169,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_113 {
fn main() {
use std::mem;
let c = '⚙';
let u = u128::from(c);
assert!(16 == mem::size_of_val(&u))
}
#[rustc_test_marker = "library/core/src/char/convert.rs - char::convert::u128::from (line 82)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/convert.rs - char::convert::u128::from (line 82)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/convert.rs",
start_line: 82,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_114 {
fn main() {
let trans_rights = '⚧'; // U+26A7
let ninjas = '🥷'; // U+1F977
assert_eq!(u16::try_from(trans_rights), Ok(0x26A7_u16));
assert!(u16::try_from(ninjas).is_err());
}
#[rustc_test_marker = "library/core/src/char/convert.rs - char::convert::u16::try_from (line 133)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/convert.rs - char::convert::u16::try_from (line 133)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/convert.rs",
start_line: 133,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_115 {
fn main() {
use std::mem;
let c = 'c';
let u = u32::from(c);
assert!(4 == mem::size_of_val(&u))
}
#[rustc_test_marker = "library/core/src/char/convert.rs - char::convert::u32::from (line 42)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/convert.rs - char::convert::u32::from (line 42)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/convert.rs",
start_line: 42,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_116 {
fn main() {
use std::mem;
let c = '👤';
let u = u64::from(c);
assert!(8 == mem::size_of_val(&u))
}
#[rustc_test_marker = "library/core/src/char/convert.rs - char::convert::u64::from (line 61)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/convert.rs - char::convert::u64::from (line 61)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/convert.rs",
start_line: 61,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_117 {
fn main() {
let a = 'ÿ'; // U+00FF
let b = 'Ā'; // U+0100
assert_eq!(u8::try_from(a), Ok(0xFF_u8));
assert!(u8::try_from(b).is_err());
}
#[rustc_test_marker = "library/core/src/char/convert.rs - char::convert::u8::try_from (line 109)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/convert.rs - char::convert::u8::try_from (line 109)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/convert.rs",
start_line: 109,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_118 {
fn main() {
fn something_which_returns_char() -> char { 'a' }
let c: char = something_which_returns_char();
assert!(c <= char::MAX);
let value_at_max = u32::from(char::MAX);
assert_eq!(char::from_u32(value_at_max), Some('\u{10FFFF}'));
assert_eq!(char::from_u32(value_at_max + 1), None);
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::MAX (line 65)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::MAX (line 65)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 65,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_119 {
fn main() {
let v = [
0xD834, 0xDD1E, 0x006d, 0x0075, 0x0073, 0xDD1E, 0x0069, 0x0063, 0xD834,
];
assert_eq!(
char::decode_utf16(v)
.map(|r| r.map_err(|e| e.unpaired_surrogate()))
.collect::<Vec<_>>(),
vec![
Ok('𝄞'),
Ok('m'), Ok('u'), Ok('s'),
Err(0xDD1E),
Ok('i'), Ok('c'),
Err(0xD834)
]
);
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::decode_utf16 (line 105)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::decode_utf16 (line 105)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 105,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_120 {
fn main() {
let v = [
0xD834, 0xDD1E, 0x006d, 0x0075, 0x0073, 0xDD1E, 0x0069, 0x0063, 0xD834,
];
assert_eq!(
char::decode_utf16(v)
.map(|r| r.unwrap_or(char::REPLACEMENT_CHARACTER))
.collect::<String>(),
"𝄞mus�ic�"
);
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::decode_utf16 (line 127)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::decode_utf16 (line 127)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 127,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_121 {
fn main() {
let mut b = [0; 2];
let result = '𝕊'.encode_utf16(&mut b);
assert_eq!(result.len(), 2);
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::encode_utf16 (line 697)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::encode_utf16 (line 697)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 697,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_122 {
fn main() {
let mut b = [0; 1];
// this panics
'𝕊'.encode_utf16(&mut b);
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::encode_utf16 (line 707)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::encode_utf16 (line 707)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 707,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::Yes,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_123 {
fn main() {
let mut b = [0; 2];
let result = 'ß'.encode_utf8(&mut b);
assert_eq!(result, "ß");
assert_eq!(result.len(), 2);
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::encode_utf8 (line 660)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::encode_utf8 (line 660)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 660,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_124 {
fn main() {
let mut b = [0; 1];
// this panics
'ß'.encode_utf8(&mut b);
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::encode_utf8 (line 672)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::encode_utf8 (line 672)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 672,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::Yes,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_125 {
fn main() {
let upper_a = 'A';
let lower_a = 'a';
let lower_z = 'z';
assert!(upper_a.eq_ignore_ascii_case(&lower_a));
assert!(upper_a.eq_ignore_ascii_case(&upper_a));
assert!(!upper_a.eq_ignore_ascii_case(&lower_z));
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::eq_ignore_ascii_case (line 1246)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::eq_ignore_ascii_case (line 1246)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 1246,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_126 {
fn main() {
for c in '\n'.escape_debug() {
print!("{c}");
}
println!();
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::escape_debug (line 469)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::escape_debug (line 469)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 469,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_127 {
fn main() {
println!("{}", '\n'.escape_debug());
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::escape_debug (line 478)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::escape_debug (line 478)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 478,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_128 {
fn main() {
println!("\\n");
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::escape_debug (line 484)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::escape_debug (line 484)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 484,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_129 {
fn main() {
assert_eq!('\n'.escape_debug().to_string(), "\\n");
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::escape_debug (line 490)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::escape_debug (line 490)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 490,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_130 {
fn main() {
for c in '"'.escape_default() {
print!("{c}");
}
println!();
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::escape_default (line 525)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::escape_default (line 525)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 525,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_131 {
fn main() {
println!("{}", '"'.escape_default());
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::escape_default (line 534)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::escape_default (line 534)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 534,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_132 {
fn main() {
println!("\\\"");
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::escape_default (line 540)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::escape_default (line 540)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 540,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_133 {
fn main() {
assert_eq!('"'.escape_default().to_string(), "\\\"");
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::escape_default (line 546)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::escape_default (line 546)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 546,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_134 {
fn main() {
for c in '❤'.escape_unicode() {
print!("{c}");
}
println!();
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::escape_unicode (line 404)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::escape_unicode (line 404)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 404,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_135 {
fn main() {
println!("{}", '❤'.escape_unicode());
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::escape_unicode (line 413)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::escape_unicode (line 413)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 413,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_136 {
fn main() {
println!("\\u{{2764}}");
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::escape_unicode (line 419)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::escape_unicode (line 419)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 419,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_137 {
fn main() {
assert_eq!('❤'.escape_unicode().to_string(), "\\u{2764}");
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::escape_unicode (line 425)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::escape_unicode (line 425)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 425,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_138 {
fn main() {
let c = char::from_digit(4, 10);
assert_eq!(Some('4'), c);
// Decimal 11 is a single digit in base 16
let c = char::from_digit(11, 16);
assert_eq!(Some('b'), c);
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::from_digit (line 252)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::from_digit (line 252)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 252,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_139 {
fn main() {
let c = char::from_digit(20, 10);
assert_eq!(None, c);
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::from_digit (line 265)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::from_digit (line 265)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 265,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_140 {
fn main() {
let _c = char::from_digit(1, 37);
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::from_digit (line 273)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::from_digit (line 273)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 273,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::Yes,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_141 {
fn main() {
let c = '💯';
let i = c as u32;
assert_eq!(128175, i);
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::from_u32 (line 151)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::from_u32 (line 151)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 151,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_142 {
fn main() {
let c = char::from_u32(0x2764);
assert_eq!(Some('❤'), c);
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::from_u32 (line 171)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::from_u32 (line 171)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 171,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_143 {
fn main() {
let c = char::from_u32(0x110000);
assert_eq!(None, c);
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::from_u32 (line 179)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::from_u32 (line 179)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 179,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_144 {
fn main() {
let c = '💯';
let i = c as u32;
assert_eq!(128175, i);
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::from_u32_unchecked (line 197)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::from_u32_unchecked (line 197)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 197,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_145 {
fn main() {
let c = unsafe { char::from_u32_unchecked(0x2764) };
assert_eq!('❤', c);
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::from_u32_unchecked (line 220)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::from_u32_unchecked (line 220)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 220,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_146 {
fn main() {
assert!('a'.is_alphabetic());
assert!('京'.is_alphabetic());
let c = '💝';
// love is many things, but it is not alphabetic
assert!(!c.is_alphabetic());
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::is_alphabetic (line 732)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::is_alphabetic (line 732)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 732,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_147 {
fn main() {
assert!('٣'.is_alphanumeric());
assert!('7'.is_alphanumeric());
assert!('৬'.is_alphanumeric());
assert!('¾'.is_alphanumeric());
assert!('①'.is_alphanumeric());
assert!('K'.is_alphanumeric());
assert!('و'.is_alphanumeric());
assert!('藏'.is_alphanumeric());
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::is_alphanumeric (line 875)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::is_alphanumeric (line 875)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 875,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_148 {
fn main() {
let ascii = 'a';
let non_ascii = '❤';
assert!(ascii.is_ascii());
assert!(!non_ascii.is_ascii());
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::is_ascii (line 1139)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::is_ascii (line 1139)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 1139,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_149 {
fn main() {
let uppercase_a = 'A';
let uppercase_g = 'G';
let a = 'a';
let g = 'g';
let zero = '0';
let percent = '%';
let space = ' ';
let lf = '\n';
let esc = '\x1b';
assert!(uppercase_a.is_ascii_alphabetic());
assert!(uppercase_g.is_ascii_alphabetic());
assert!(a.is_ascii_alphabetic());
assert!(g.is_ascii_alphabetic());
assert!(!zero.is_ascii_alphabetic());
assert!(!percent.is_ascii_alphabetic());
assert!(!space.is_ascii_alphabetic());
assert!(!lf.is_ascii_alphabetic());
assert!(!esc.is_ascii_alphabetic());
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::is_ascii_alphabetic (line 1321)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::is_ascii_alphabetic (line 1321)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 1321,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_150 {
fn main() {
let uppercase_a = 'A';
let uppercase_g = 'G';
let a = 'a';
let g = 'g';
let zero = '0';
let percent = '%';
let space = ' ';
let lf = '\n';
let esc = '\x1b';
assert!(uppercase_a.is_ascii_alphanumeric());
assert!(uppercase_g.is_ascii_alphanumeric());
assert!(a.is_ascii_alphanumeric());
assert!(g.is_ascii_alphanumeric());
assert!(zero.is_ascii_alphanumeric());
assert!(!percent.is_ascii_alphanumeric());
assert!(!space.is_ascii_alphanumeric());
assert!(!lf.is_ascii_alphanumeric());
assert!(!esc.is_ascii_alphanumeric());
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::is_ascii_alphanumeric (line 1426)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::is_ascii_alphanumeric (line 1426)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 1426,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_151 {
fn main() {
let uppercase_a = 'A';
let uppercase_g = 'G';
let a = 'a';
let g = 'g';
let zero = '0';
let percent = '%';
let space = ' ';
let lf = '\n';
let esc = '\x1b';
assert!(!uppercase_a.is_ascii_control());
assert!(!uppercase_g.is_ascii_control());
assert!(!a.is_ascii_control());
assert!(!g.is_ascii_control());
assert!(!zero.is_ascii_control());
assert!(!percent.is_ascii_control());
assert!(!space.is_ascii_control());
assert!(lf.is_ascii_control());
assert!(esc.is_ascii_control());
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::is_ascii_control (line 1691)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::is_ascii_control (line 1691)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 1691,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_152 {
fn main() {
let uppercase_a = 'A';
let uppercase_g = 'G';
let a = 'a';
let g = 'g';
let zero = '0';
let percent = '%';
let space = ' ';
let lf = '\n';
let esc = '\x1b';
assert!(!uppercase_a.is_ascii_digit());
assert!(!uppercase_g.is_ascii_digit());
assert!(!a.is_ascii_digit());
assert!(!g.is_ascii_digit());
assert!(zero.is_ascii_digit());
assert!(!percent.is_ascii_digit());
assert!(!space.is_ascii_digit());
assert!(!lf.is_ascii_digit());
assert!(!esc.is_ascii_digit());
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::is_ascii_digit (line 1460)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::is_ascii_digit (line 1460)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 1460,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_153 {
fn main() {
let uppercase_a = 'A';
let uppercase_g = 'G';
let a = 'a';
let g = 'g';
let zero = '0';
let percent = '%';
let space = ' ';
let lf = '\n';
let esc = '\x1b';
assert!(uppercase_a.is_ascii_graphic());
assert!(uppercase_g.is_ascii_graphic());
assert!(a.is_ascii_graphic());
assert!(g.is_ascii_graphic());
assert!(zero.is_ascii_graphic());
assert!(percent.is_ascii_graphic());
assert!(!space.is_ascii_graphic());
assert!(!lf.is_ascii_graphic());
assert!(!esc.is_ascii_graphic());
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::is_ascii_graphic (line 1604)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::is_ascii_graphic (line 1604)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 1604,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_154 {
fn main() {
let uppercase_a = 'A';
let uppercase_g = 'G';
let a = 'a';
let g = 'g';
let zero = '0';
let percent = '%';
let space = ' ';
let lf = '\n';
let esc = '\x1b';
assert!(uppercase_a.is_ascii_hexdigit());
assert!(!uppercase_g.is_ascii_hexdigit());
assert!(a.is_ascii_hexdigit());
assert!(!g.is_ascii_hexdigit());
assert!(zero.is_ascii_hexdigit());
assert!(!percent.is_ascii_hexdigit());
assert!(!space.is_ascii_hexdigit());
assert!(!lf.is_ascii_hexdigit());
assert!(!esc.is_ascii_hexdigit());
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::is_ascii_hexdigit (line 1529)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::is_ascii_hexdigit (line 1529)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 1529,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_155 {
fn main() {
let uppercase_a = 'A';
let uppercase_g = 'G';
let a = 'a';
let g = 'g';
let zero = '0';
let percent = '%';
let space = ' ';
let lf = '\n';
let esc = '\x1b';
assert!(!uppercase_a.is_ascii_lowercase());
assert!(!uppercase_g.is_ascii_lowercase());
assert!(a.is_ascii_lowercase());
assert!(g.is_ascii_lowercase());
assert!(!zero.is_ascii_lowercase());
assert!(!percent.is_ascii_lowercase());
assert!(!space.is_ascii_lowercase());
assert!(!lf.is_ascii_lowercase());
assert!(!esc.is_ascii_lowercase());
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::is_ascii_lowercase (line 1389)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::is_ascii_lowercase (line 1389)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 1389,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_156 {
fn main() {
let uppercase_a = 'A';
let uppercase_g = 'G';
let a = 'a';
let g = 'g';
let zero = '0';
let percent = '%';
let space = ' ';
let lf = '\n';
let esc = '\x1b';
assert!(!uppercase_a.is_ascii_punctuation());
assert!(!uppercase_g.is_ascii_punctuation());
assert!(!a.is_ascii_punctuation());
assert!(!g.is_ascii_punctuation());
assert!(!zero.is_ascii_punctuation());
assert!(percent.is_ascii_punctuation());
assert!(!space.is_ascii_punctuation());
assert!(!lf.is_ascii_punctuation());
assert!(!esc.is_ascii_punctuation());
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::is_ascii_punctuation (line 1567)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::is_ascii_punctuation (line 1567)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 1567,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_157 {
fn main() {
let uppercase_a = 'A';
let uppercase_g = 'G';
let a = 'a';
let g = 'g';
let zero = '0';
let percent = '%';
let space = ' ';
let lf = '\n';
let esc = '\x1b';
assert!(uppercase_a.is_ascii_uppercase());
assert!(uppercase_g.is_ascii_uppercase());
assert!(!a.is_ascii_uppercase());
assert!(!g.is_ascii_uppercase());
assert!(!zero.is_ascii_uppercase());
assert!(!percent.is_ascii_uppercase());
assert!(!space.is_ascii_uppercase());
assert!(!lf.is_ascii_uppercase());
assert!(!esc.is_ascii_uppercase());
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::is_ascii_uppercase (line 1355)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::is_ascii_uppercase (line 1355)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 1355,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_158 {
fn main() {
let uppercase_a = 'A';
let uppercase_g = 'G';
let a = 'a';
let g = 'g';
let zero = '0';
let percent = '%';
let space = ' ';
let lf = '\n';
let esc = '\x1b';
assert!(!uppercase_a.is_ascii_whitespace());
assert!(!uppercase_g.is_ascii_whitespace());
assert!(!a.is_ascii_whitespace());
assert!(!g.is_ascii_whitespace());
assert!(!zero.is_ascii_whitespace());
assert!(!percent.is_ascii_whitespace());
assert!(space.is_ascii_whitespace());
assert!(lf.is_ascii_whitespace());
assert!(!esc.is_ascii_whitespace());
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::is_ascii_whitespace (line 1655)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::is_ascii_whitespace (line 1655)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 1655,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_159 {
fn main() {
assert!('œ'.is_control());
assert!(!'q'.is_control());
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::is_control (line 906)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::is_control (line 906)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 906,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_160 {
fn main() {
assert!('1'.is_digit(10));
assert!('f'.is_digit(16));
assert!(!'f'.is_digit(10));
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::is_digit (line 313)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::is_digit (line 313)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 313,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_161 {
fn main() {
'1'.is_digit(37);
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::is_digit (line 321)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::is_digit (line 321)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 321,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::Yes,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_162 {
fn main() {
assert!('a'.is_lowercase());
assert!('δ'.is_lowercase());
assert!(!'A'.is_lowercase());
assert!(!'Δ'.is_lowercase());
// The various Chinese scripts and punctuation do not have case, and so:
assert!(!'中'.is_lowercase());
assert!(!' '.is_lowercase());
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::is_lowercase (line 763)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::is_lowercase (line 763)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 763,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_163 {
fn main() {
assert!('٣'.is_numeric());
assert!('7'.is_numeric());
assert!('৬'.is_numeric());
assert!('¾'.is_numeric());
assert!('①'.is_numeric());
assert!(!'K'.is_numeric());
assert!(!'و'.is_numeric());
assert!(!'藏'.is_numeric());
assert!(!'三'.is_numeric());
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::is_numeric (line 955)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::is_numeric (line 955)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 955,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_164 {
fn main() {
assert!(!'a'.is_uppercase());
assert!(!'δ'.is_uppercase());
assert!('A'.is_uppercase());
assert!('Δ'.is_uppercase());
// The various Chinese scripts and punctuation do not have case, and so:
assert!(!'中'.is_uppercase());
assert!(!' '.is_uppercase());
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::is_uppercase (line 805)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::is_uppercase (line 805)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 805,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_165 {
fn main() {
assert!(' '.is_whitespace());
// line break
assert!('\n'.is_whitespace());
// a non-breaking space
assert!('\u{A0}'.is_whitespace());
assert!(!'越'.is_whitespace());
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::is_whitespace (line 845)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::is_whitespace (line 845)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 845,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_166 {
fn main() {
let n = 'ß'.len_utf16();
assert_eq!(n, 1);
let len = '💣'.len_utf16();
assert_eq!(len, 2);
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::len_utf16 (line 633)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::len_utf16 (line 633)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 633,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_167 {
fn main() {
let len = 'A'.len_utf8();
assert_eq!(len, 1);
let len = 'ß'.len_utf8();
assert_eq!(len, 2);
let len = 'ℝ'.len_utf8();
assert_eq!(len, 3);
let len = '💣'.len_utf8();
assert_eq!(len, 4);
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::len_utf8 (line 572)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::len_utf8 (line 572)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 572,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_168 {
fn main() {
let eastern = '東';
let capital = '京';
// both can be represented as three bytes
assert_eq!(3, eastern.len_utf8());
assert_eq!(3, capital.len_utf8());
// as a &str, these two are encoded in UTF-8
let tokyo = "東京";
let len = eastern.len_utf8() + capital.len_utf8();
// we can see that they take six bytes total...
assert_eq!(6, tokyo.len());
// ... just like the &str
assert_eq!(len, tokyo.len());
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::len_utf8 (line 589)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::len_utf8 (line 589)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 589,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_169 {
fn main() {
let mut ascii = 'A';
ascii.make_ascii_lowercase();
assert_eq!('a', ascii);
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::make_ascii_lowercase (line 1299)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::make_ascii_lowercase (line 1299)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 1299,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_170 {
fn main() {
let mut ascii = 'a';
ascii.make_ascii_uppercase();
assert_eq!('A', ascii);
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::make_ascii_uppercase (line 1274)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::make_ascii_uppercase (line 1274)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 1274,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_171 {
fn main() {
let ascii = 'A';
let non_ascii = '❤';
assert_eq!('a', ascii.to_ascii_lowercase());
assert_eq!('❤', non_ascii.to_ascii_lowercase());
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::to_ascii_lowercase (line 1218)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::to_ascii_lowercase (line 1218)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 1218,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_172 {
fn main() {
let ascii = 'a';
let non_ascii = '❤';
assert_eq!('A', ascii.to_ascii_uppercase());
assert_eq!('❤', non_ascii.to_ascii_uppercase());
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::to_ascii_uppercase (line 1184)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::to_ascii_uppercase (line 1184)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 1184,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_173 {
fn main() {
assert_eq!('1'.to_digit(10), Some(1));
assert_eq!('f'.to_digit(16), Some(15));
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::to_digit (line 356)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::to_digit (line 356)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 356,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_174 {
fn main() {
assert_eq!('f'.to_digit(10), None);
assert_eq!('z'.to_digit(16), None);
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::to_digit (line 363)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::to_digit (line 363)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 363,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_175 {
fn main() {
let _ = '1'.to_digit(37);
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::to_digit (line 370)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::to_digit (line 370)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 370,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::Yes,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_176 {
fn main() {
for c in 'İ'.to_lowercase() {
print!("{c}");
}
println!();
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::to_lowercase (line 1004)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::to_lowercase (line 1004)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 1004,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_177 {
fn main() {
println!("{}", 'İ'.to_lowercase());
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::to_lowercase (line 1013)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::to_lowercase (line 1013)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 1013,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_178 {
fn main() {
println!("i\u{307}");
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::to_lowercase (line 1019)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::to_lowercase (line 1019)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 1019,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_179 {
fn main() {
assert_eq!('C'.to_lowercase().to_string(), "c");
// Sometimes the result is more than one character:
assert_eq!('İ'.to_lowercase().to_string(), "i\u{307}");
// Characters that do not have both uppercase and lowercase
// convert into themselves.
assert_eq!('山'.to_lowercase().to_string(), "山");
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::to_lowercase (line 1025)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::to_lowercase (line 1025)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 1025,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_180 {
fn main() {
for c in 'ß'.to_uppercase() {
print!("{c}");
}
println!();
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::to_uppercase (line 1071)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::to_uppercase (line 1071)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 1071,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_181 {
fn main() {
println!("{}", 'ß'.to_uppercase());
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::to_uppercase (line 1080)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::to_uppercase (line 1080)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 1080,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_182 {
fn main() {
println!("SS");
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::to_uppercase (line 1086)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::to_uppercase (line 1086)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 1086,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_183 {
fn main() {
assert_eq!('c'.to_uppercase().to_string(), "C");
// Sometimes the result is more than one character:
assert_eq!('ß'.to_uppercase().to_string(), "SS");
// Characters that do not have both uppercase and lowercase
// convert into themselves.
assert_eq!('山'.to_uppercase().to_string(), "山");
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::to_uppercase (line 1092)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::to_uppercase (line 1092)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 1092,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_184 {
fn main() {
let upper_i = 'i'.to_uppercase().to_string();
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::to_uppercase (line 1112)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::to_uppercase (line 1112)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 1112,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_185 {
fn main() {
let upper_i = 'i'.to_uppercase().to_string();
assert_eq!(upper_i, "I");
}
#[rustc_test_marker = "library/core/src/char/methods.rs - char::methods::char::to_uppercase (line 1120)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/char/methods.rs - char::methods::char::to_uppercase (line 1120)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/char/methods.rs",
start_line: 1120,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_186 {
fn main() {
let s = String::new(); // String type implements Clone
let copy = s.clone(); // so we can clone it
}
#[rustc_test_marker = "library/core/src/clone.rs - clone (line 16)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/clone.rs - clone (line 16)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/clone.rs",
start_line: 16,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_187 {
#[derive(Clone)] // we add the Clone trait to Morpheus struct
struct Morpheus {
blue_pill: f32,
red_pill: i64,
}
fn main() {
let f = Morpheus { blue_pill: 0.0, red_pill: 0 };
let copy = f.clone(); // and now we can clone it!
}
#[rustc_test_marker = "library/core/src/clone.rs - clone (line 24)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/clone.rs - clone (line 24)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/clone.rs",
start_line: 24,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_188 {
fn main() {
#[derive(Clone)]
struct Reading<T> {
frequency: T,
}
}
#[rustc_test_marker = "library/core/src/clone.rs - clone::Clone (line 59)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/clone.rs - clone::Clone (line 59)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/clone.rs",
start_line: 59,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_189 {
fn main() {
struct Generate<T>(fn() -> T);
impl<T> Copy for Generate<T> {}
impl<T> Clone for Generate<T> {
fn clone(&self) -> Self {
*self
}
}
}
#[rustc_test_marker = "library/core/src/clone.rs - clone::Clone (line 77)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/clone.rs - clone::Clone (line 77)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/clone.rs",
start_line: 77,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_190 {
fn main() {
#[derive(Copy, Clone)]
struct Generate<T>(fn() -> T);
}
#[rustc_test_marker = "library/core/src/clone.rs - clone::Clone (line 91)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/clone.rs - clone::Clone (line 91)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/clone.rs",
start_line: 91,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_191 {
fn main() {
struct Generate<T>(fn() -> T);
// Automatically derived
impl<T: Copy> Copy for Generate<T> { }
// Automatically derived
impl<T: Clone> Clone for Generate<T> {
fn clone(&self) -> Generate<T> {
Generate(Clone::clone(&self.0))
}
}
}
#[rustc_test_marker = "library/core/src/clone.rs - clone::Clone (line 98)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/clone.rs - clone::Clone (line 98)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/clone.rs",
start_line: 98,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_192 {
fn main() {
#![allow(noop_method_call)]
let hello = "Hello"; // &str implements Clone
assert_eq!("Hello", hello.clone());
}
#[rustc_test_marker = "library/core/src/clone.rs - clone::Clone::clone (line 152)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/clone.rs - clone::Clone::clone (line 152)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/clone.rs",
start_line: 152,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_193 {
fn main() {
enum BookFormat { Paperback, Hardback, Ebook }
struct Book {
isbn: i32,
format: BookFormat,
}
impl PartialEq for Book {
fn eq(&self, other: &Self) -> bool {
self.isbn == other.isbn
}
}
impl Eq for Book {}
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::Eq (line 312)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::Eq (line 312)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 312,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_194 {
fn main() {
#[derive(PartialEq, Eq, PartialOrd, Ord)]
enum E {
Top,
Bottom,
}
assert!(E::Top < E::Bottom);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::Ord (line 743)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::Ord (line 743)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 743,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_195 {
fn main() {
#[derive(PartialEq, Eq, PartialOrd, Ord)]
enum E {
Top = 2,
Bottom = 1,
}
assert!(E::Bottom < E::Top);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::Ord (line 756)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::Ord (line 756)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 756,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_196 {
fn main() {
use std::cmp::Ordering;
#[derive(Eq)]
struct Person {
id: u32,
name: String,
height: u32,
}
impl Ord for Person {
fn cmp(&self, other: &Self) -> Ordering {
self.height.cmp(&other.height)
}
}
impl PartialOrd for Person {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl PartialEq for Person {
fn eq(&self, other: &Self) -> bool {
self.height == other.height
}
}
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::Ord (line 786)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::Ord (line 786)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 786,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_197 {
fn main() {
assert_eq!((-3).clamp(-2, 1), -2);
assert_eq!(0.clamp(-2, 1), 0);
assert_eq!(2.clamp(-2, 1), 1);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::Ord::clamp (line 895)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::Ord::clamp (line 895)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 895,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_198 {
fn main() {
use std::cmp::Ordering;
assert_eq!(5.cmp(&10), Ordering::Less);
assert_eq!(10.cmp(&5), Ordering::Greater);
assert_eq!(5.cmp(&5), Ordering::Equal);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::Ord::cmp (line 830)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::Ord::cmp (line 830)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 830,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_199 {
fn main() {
assert_eq!(1.max(2), 2);
assert_eq!(2.max(2), 2);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::Ord::max (line 848)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::Ord::max (line 848)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 848,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_200 {
fn main() {
assert_eq!(1.min(2), 1);
assert_eq!(2.min(2), 2);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::Ord::min (line 869)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::Ord::min (line 869)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 869,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_201 {
fn main() {
use std::cmp::Ordering;
assert_eq!(1.cmp(&2), Ordering::Less);
assert_eq!(1.cmp(&1), Ordering::Equal);
assert_eq!(2.cmp(&1), Ordering::Greater);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::Ordering (line 368)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::Ordering (line 368)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 368,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_202 {
fn main() {
use std::cmp::Ordering;
assert_eq!(Ordering::Less.is_eq(), false);
assert_eq!(Ordering::Equal.is_eq(), true);
assert_eq!(Ordering::Greater.is_eq(), false);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::Ordering::is_eq (line 401)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::Ordering::is_eq (line 401)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 401,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_203 {
fn main() {
use std::cmp::Ordering;
assert_eq!(Ordering::Less.is_ge(), false);
assert_eq!(Ordering::Equal.is_ge(), true);
assert_eq!(Ordering::Greater.is_ge(), true);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::Ordering::is_ge (line 496)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::Ordering::is_ge (line 496)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 496,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_204 {
fn main() {
use std::cmp::Ordering;
assert_eq!(Ordering::Less.is_gt(), false);
assert_eq!(Ordering::Equal.is_gt(), false);
assert_eq!(Ordering::Greater.is_gt(), true);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::Ordering::is_gt (line 458)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::Ordering::is_gt (line 458)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 458,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_205 {
fn main() {
use std::cmp::Ordering;
assert_eq!(Ordering::Less.is_le(), true);
assert_eq!(Ordering::Equal.is_le(), true);
assert_eq!(Ordering::Greater.is_le(), false);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::Ordering::is_le (line 477)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::Ordering::is_le (line 477)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 477,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_206 {
fn main() {
use std::cmp::Ordering;
assert_eq!(Ordering::Less.is_lt(), true);
assert_eq!(Ordering::Equal.is_lt(), false);
assert_eq!(Ordering::Greater.is_lt(), false);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::Ordering::is_lt (line 439)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::Ordering::is_lt (line 439)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 439,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_207 {
fn main() {
use std::cmp::Ordering;
assert_eq!(Ordering::Less.is_ne(), true);
assert_eq!(Ordering::Equal.is_ne(), false);
assert_eq!(Ordering::Greater.is_ne(), true);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::Ordering::is_ne (line 420)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::Ordering::is_ne (line 420)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 420,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_208 {
fn main() {
use std::cmp::Ordering;
assert_eq!(Ordering::Less.reverse(), Ordering::Greater);
assert_eq!(Ordering::Equal.reverse(), Ordering::Equal);
assert_eq!(Ordering::Greater.reverse(), Ordering::Less);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::Ordering::reverse (line 521)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::Ordering::reverse (line 521)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 521,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_209 {
fn main() {
let data: &mut [_] = &mut [2, 10, 5, 8];
// sort the array from largest to smallest.
data.sort_by(|a, b| a.cmp(b).reverse());
let b: &mut [_] = &mut [10, 8, 5, 2];
assert!(data == b);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::Ordering::reverse (line 531)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::Ordering::reverse (line 531)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 531,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_210 {
fn main() {
use std::cmp::Ordering;
let result = Ordering::Equal.then(Ordering::Less);
assert_eq!(result, Ordering::Less);
let result = Ordering::Less.then(Ordering::Equal);
assert_eq!(result, Ordering::Less);
let result = Ordering::Less.then(Ordering::Greater);
assert_eq!(result, Ordering::Less);
let result = Ordering::Equal.then(Ordering::Equal);
assert_eq!(result, Ordering::Equal);
let x: (i64, i64, i64) = (1, 2, 7);
let y: (i64, i64, i64) = (1, 5, 3);
let result = x.0.cmp(&y.0).then(x.1.cmp(&y.1)).then(x.2.cmp(&y.2));
assert_eq!(result, Ordering::Less);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::Ordering::then (line 558)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::Ordering::then (line 558)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 558,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_211 {
fn main() {
use std::cmp::Ordering;
let result = Ordering::Equal.then_with(|| Ordering::Less);
assert_eq!(result, Ordering::Less);
let result = Ordering::Less.then_with(|| Ordering::Equal);
assert_eq!(result, Ordering::Less);
let result = Ordering::Less.then_with(|| Ordering::Greater);
assert_eq!(result, Ordering::Less);
let result = Ordering::Equal.then_with(|| Ordering::Equal);
assert_eq!(result, Ordering::Equal);
let x: (i64, i64, i64) = (1, 2, 7);
let y: (i64, i64, i64) = (1, 5, 3);
let result = x.0.cmp(&y.0).then_with(|| x.1.cmp(&y.1)).then_with(|| x.2.cmp(&y.2));
assert_eq!(result, Ordering::Less);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::Ordering::then_with (line 597)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::Ordering::then_with (line 597)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 597,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_212 {
fn main() {
enum BookFormat {
Paperback,
Hardback,
Ebook,
}
struct Book {
isbn: i32,
format: BookFormat,
}
impl PartialEq for Book {
fn eq(&self, other: &Self) -> bool {
self.isbn == other.isbn
}
}
let b1 = Book { isbn: 3, format: BookFormat::Paperback };
let b2 = Book { isbn: 3, format: BookFormat::Ebook };
let b3 = Book { isbn: 10, format: BookFormat::Paperback };
assert!(b1 == b2);
assert!(b1 != b3);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::PartialEq (line 112)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::PartialEq (line 112)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 112,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_213 {
fn main() {
#[derive(PartialEq)]
enum BookFormat {
Paperback,
Hardback,
Ebook,
}
struct Book {
isbn: i32,
format: BookFormat,
}
// Implement <Book> == <BookFormat> comparisons
impl PartialEq<BookFormat> for Book {
fn eq(&self, other: &BookFormat) -> bool {
self.format == *other
}
}
// Implement <BookFormat> == <Book> comparisons
impl PartialEq<Book> for BookFormat {
fn eq(&self, other: &Book) -> bool {
*self == other.format
}
}
let b1 = Book { isbn: 3, format: BookFormat::Paperback };
assert!(b1 == BookFormat::Paperback);
assert!(BookFormat::Ebook != b1);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::PartialEq (line 143)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::PartialEq (line 143)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 143,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_214 {
#[derive(PartialEq)]
enum BookFormat {
Paperback,
Hardback,
Ebook,
}
#[derive(PartialEq)]
struct Book {
isbn: i32,
format: BookFormat,
}
impl PartialEq<BookFormat> for Book {
fn eq(&self, other: &BookFormat) -> bool {
self.format == *other
}
}
impl PartialEq<Book> for BookFormat {
fn eq(&self, other: &Book) -> bool {
*self == other.format
}
}
fn main() {
let b1 = Book { isbn: 1, format: BookFormat::Paperback };
let b2 = Book { isbn: 2, format: BookFormat::Paperback };
assert!(b1 == BookFormat::Paperback);
assert!(BookFormat::Paperback == b2);
// The following should hold by transitivity but doesn't.
assert!(b1 == b2); // <-- PANICS
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::PartialEq (line 188)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::PartialEq (line 188)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 188,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::Yes,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_215 {
fn main() {
let x: u32 = 0;
let y: u32 = 1;
assert_eq!(x == y, false);
assert_eq!(x.eq(&y), false);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::PartialEq (line 228)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::PartialEq (line 228)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 228,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_216 {
fn main() {
let a = f64::sqrt(-1.0);
assert_eq!(a <= a, false);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::PartialOrd (line 1005)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::PartialOrd (line 1005)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 1005,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_217 {
fn main() {
#[derive(PartialEq, PartialOrd)]
enum E {
Top,
Bottom,
}
assert!(E::Top < E::Bottom);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::PartialOrd (line 1023)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::PartialOrd (line 1023)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 1023,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_218 {
fn main() {
#[derive(PartialEq, PartialOrd)]
enum E {
Top = 2,
Bottom = 1,
}
assert!(E::Bottom < E::Top);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::PartialOrd (line 1036)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::PartialOrd (line 1036)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 1036,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_219 {
fn main() {
use std::cmp::Ordering;
#[derive(Eq)]
struct Person {
id: u32,
name: String,
height: u32,
}
impl PartialOrd for Person {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl Ord for Person {
fn cmp(&self, other: &Self) -> Ordering {
self.height.cmp(&other.height)
}
}
impl PartialEq for Person {
fn eq(&self, other: &Self) -> bool {
self.height == other.height
}
}
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::PartialOrd (line 1059)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::PartialOrd (line 1059)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 1059,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_220 {
fn main() {
use std::cmp::Ordering;
struct Person {
id: u32,
name: String,
height: f64,
}
impl PartialOrd for Person {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
self.height.partial_cmp(&other.height)
}
}
impl PartialEq for Person {
fn eq(&self, other: &Self) -> bool {
self.height == other.height
}
}
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::PartialOrd (line 1092)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::PartialOrd (line 1092)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 1092,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_221 {
fn main() {
let x: u32 = 0;
let y: u32 = 1;
assert_eq!(x < y, true);
assert_eq!(x.lt(&y), true);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::PartialOrd (line 1116)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::PartialOrd (line 1116)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 1116,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_222 {
fn main() {
assert_eq!(1.0 >= 1.0, true);
assert_eq!(1.0 >= 2.0, false);
assert_eq!(2.0 >= 1.0, true);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::PartialOrd::ge (line 1224)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::PartialOrd::ge (line 1224)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 1224,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_223 {
fn main() {
assert_eq!(1.0 > 1.0, false);
assert_eq!(1.0 > 2.0, false);
assert_eq!(2.0 > 1.0, true);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::PartialOrd::gt (line 1206)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::PartialOrd::gt (line 1206)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 1206,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_224 {
fn main() {
assert_eq!(1.0 <= 1.0, true);
assert_eq!(1.0 <= 2.0, true);
assert_eq!(2.0 <= 1.0, false);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::PartialOrd::le (line 1189)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::PartialOrd::le (line 1189)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 1189,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_225 {
fn main() {
assert_eq!(1.0 < 1.0, false);
assert_eq!(1.0 < 2.0, true);
assert_eq!(2.0 < 1.0, false);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::PartialOrd::lt (line 1171)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::PartialOrd::lt (line 1171)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 1171,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_226 {
fn main() {
use std::cmp::Ordering;
let result = 1.0.partial_cmp(&2.0);
assert_eq!(result, Some(Ordering::Less));
let result = 1.0.partial_cmp(&1.0);
assert_eq!(result, Some(Ordering::Equal));
let result = 2.0.partial_cmp(&1.0);
assert_eq!(result, Some(Ordering::Greater));
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::PartialOrd::partial_cmp (line 1143)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::PartialOrd::partial_cmp (line 1143)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 1143,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_227 {
fn main() {
let result = f64::NAN.partial_cmp(&1.0);
assert_eq!(result, None);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::PartialOrd::partial_cmp (line 1158)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::PartialOrd::partial_cmp (line 1158)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 1158,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_228 {
fn main() {
use std::cmp::Reverse;
let mut v = vec![1, 2, 3, 4, 5, 6];
v.sort_by_key(|&num| (num > 3, Reverse(num)));
assert_eq!(v, vec![3, 2, 1, 6, 5, 4]);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::Reverse (line 638)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::Reverse (line 638)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 638,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_229 {
fn main() {
use std::cmp;
assert_eq!(cmp::max(1, 2), 2);
assert_eq!(cmp::max(2, 2), 2);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::max (line 1324)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::max (line 1324)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 1324,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_230 {
fn main() {
use std::cmp;
let result = cmp::max_by(-2, 1, |x: &i32, y: &i32| x.abs().cmp(&y.abs()));
assert_eq!(result, -2);
let result = cmp::max_by(-2, 2, |x: &i32, y: &i32| x.abs().cmp(&y.abs())) ;
assert_eq!(result, 2);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::max_by (line 1344)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::max_by (line 1344)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 1344,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_231 {
fn main() {
use std::cmp;
let result = cmp::max_by_key(-2, 1, |x: &i32| x.abs());
assert_eq!(result, -2);
let result = cmp::max_by_key(-2, 2, |x: &i32| x.abs());
assert_eq!(result, 2);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::max_by_key (line 1369)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::max_by_key (line 1369)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 1369,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_232 {
fn main() {
use std::cmp;
assert_eq!(cmp::min(1, 2), 1);
assert_eq!(cmp::min(2, 2), 2);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::min (line 1255)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::min (line 1255)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 1255,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_233 {
fn main() {
use std::cmp;
let result = cmp::min_by(-2, 1, |x: &i32, y: &i32| x.abs().cmp(&y.abs()));
assert_eq!(result, 1);
let result = cmp::min_by(-2, 3, |x: &i32, y: &i32| x.abs().cmp(&y.abs()));
assert_eq!(result, -2);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::min_by (line 1275)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::min_by (line 1275)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 1275,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_234 {
fn main() {
use std::cmp;
let result = cmp::min_by_key(-2, 1, |x: &i32| x.abs());
assert_eq!(result, 1);
let result = cmp::min_by_key(-2, 2, |x: &i32| x.abs());
assert_eq!(result, -2);
}
#[rustc_test_marker = "library/core/src/cmp.rs - cmp::min_by_key (line 1300)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/cmp.rs - cmp::min_by_key (line 1300)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/cmp.rs",
start_line: 1300,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_235 {
fn main() {
let mut x = Box::new(5i32);
// Avoid this:
// let y: &mut i32 = x.as_mut();
// Better just write:
let y: &mut i32 = &mut x;
}
#[rustc_test_marker = "library/core/src/convert/mod.rs - convert::AsMut (line 249)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/convert/mod.rs - convert::AsMut (line 249)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/convert/mod.rs",
start_line: 249,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_236 {
fn main() {
use core::ops::{Deref, DerefMut};
struct SomeType;
impl Deref for SomeType {
type Target = [u8];
fn deref(&self) -> &[u8] {
&[]
}
}
impl DerefMut for SomeType {
fn deref_mut(&mut self) -> &mut [u8] {
&mut []
}
}
impl<T> AsMut<T> for SomeType
where
<SomeType as Deref>::Target: AsMut<T>,
{
fn as_mut(&mut self) -> &mut T {
self.deref_mut().as_mut()
}
}
}
#[rustc_test_marker = "library/core/src/convert/mod.rs - convert::AsMut (line 262)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/convert/mod.rs - convert::AsMut (line 262)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/convert/mod.rs",
start_line: 262,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_237 {
struct Document {
info: String,
content: Vec<u8>,
}
impl<T: ?Sized> AsMut<T> for Document
where
Vec<u8>: AsMut<T>,
{
fn as_mut(&mut self) -> &mut T {
self.content.as_mut()
}
}
fn caesar<T: AsMut<[u8]>>(data: &mut T, key: u8) {
for byte in data.as_mut() {
*byte = byte.wrapping_add(key);
}
}
fn null_terminate<T: AsMut<Vec<u8>>>(data: &mut T) {
// Using a non-generic inner function, which contains most of the
// functionality, helps to minimize monomorphization overhead.
fn doit(data: &mut Vec<u8>) {
let len = data.len();
if len == 0 || data[len-1] != 0 {
data.push(0);
}
}
doit(data.as_mut());
}
fn main() {
let mut v: Vec<u8> = vec![1, 2, 3];
caesar(&mut v, 5);
assert_eq!(v, [6, 7, 8]);
null_terminate(&mut v);
assert_eq!(v, [6, 7, 8, 0]);
let mut doc = Document {
info: String::from("Example"),
content: vec![17, 19, 8],
};
caesar(&mut doc, 1);
assert_eq!(doc.content, [18, 20, 9]);
null_terminate(&mut doc);
assert_eq!(doc.content, [18, 20, 9, 0]);
}
#[rustc_test_marker = "library/core/src/convert/mod.rs - convert::AsMut (line 315)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/convert/mod.rs - convert::AsMut (line 315)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/convert/mod.rs",
start_line: 315,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_238 {
fn main() {
let x = Box::new(5i32);
// Avoid this:
// let y: &i32 = x.as_ref();
// Better just write:
let y: &i32 = &x;
}
#[rustc_test_marker = "library/core/src/convert/mod.rs - convert::AsRef (line 143)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/convert/mod.rs - convert::AsRef (line 143)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/convert/mod.rs",
start_line: 143,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_239 {
fn main() {
use core::ops::Deref;
struct SomeType;
impl Deref for SomeType {
type Target = [u8];
fn deref(&self) -> &[u8] {
&[]
}
}
impl<T> AsRef<T> for SomeType
where
T: ?Sized,
<SomeType as Deref>::Target: AsRef<T>,
{
fn as_ref(&self) -> &T {
self.deref().as_ref()
}
}
}
#[rustc_test_marker = "library/core/src/convert/mod.rs - convert::AsRef (line 155)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/convert/mod.rs - convert::AsRef (line 155)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/convert/mod.rs",
start_line: 155,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_240 {
fn main() {
fn is_hello<T: AsRef<str>>(s: T) {
assert_eq!("hello", s.as_ref());
}
let s = "hello";
is_hello(s);
let s = "hello".to_string();
is_hello(s);
}
#[rustc_test_marker = "library/core/src/convert/mod.rs - convert::AsRef (line 205)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/convert/mod.rs - convert::AsRef (line 205)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/convert/mod.rs",
start_line: 205,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_241 {
fn main() {
let string = "hello".to_string();
let other_string = String::from("hello");
assert_eq!(string, other_string);
}
#[rustc_test_marker = "library/core/src/convert/mod.rs - convert::From (line 529)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/convert/mod.rs - convert::From (line 529)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/convert/mod.rs",
start_line: 529,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_242 {
fn main() {
use std::fs;
use std::io;
use std::num;
enum CliError {
IoError(io::Error),
ParseError(num::ParseIntError),
}
impl From<io::Error> for CliError {
fn from(error: io::Error) -> Self {
CliError::IoError(error)
}
}
impl From<num::ParseIntError> for CliError {
fn from(error: num::ParseIntError) -> Self {
CliError::ParseError(error)
}
}
fn open_and_parse_file(file_name: &str) -> Result<i32, CliError> {
let mut contents = fs::read_to_string(&file_name)?;
let num: i32 = contents.trim().parse()?;
Ok(num)
}
}
#[rustc_test_marker = "library/core/src/convert/mod.rs - convert::From (line 542)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/convert/mod.rs - convert::From (line 542)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/convert/mod.rs",
start_line: 542,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_243 {
#[rustc_test_marker = "library/core/src/convert/mod.rs - convert::Infallible (line 866)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/convert/mod.rs - convert::Infallible (line 866)"),
ignore: true,
ignore_message: None,
source_file: "library/core/src/convert/mod.rs",
start_line: 866,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_244 {
#[rustc_test_marker = "library/core/src/convert/mod.rs - convert::Infallible (line 882)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/convert/mod.rs - convert::Infallible (line 882)"),
ignore: true,
ignore_message: None,
source_file: "library/core/src/convert/mod.rs",
start_line: 882,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_245 {
fn main() {
trait MyTrait {}
impl MyTrait for fn() -> ! {}
impl MyTrait for fn() -> std::convert::Infallible {}
}
#[rustc_test_marker = "library/core/src/convert/mod.rs - convert::Infallible (line 892)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/convert/mod.rs - convert::Infallible (line 892)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/convert/mod.rs",
start_line: 892,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_246 {
fn main() {
#![allow(non_local_definitions)]
struct Wrapper<T>(Vec<T>);
impl<T> From<Wrapper<T>> for Vec<T> {
fn from(w: Wrapper<T>) -> Vec<T> {
w.0
}
}
}
#[rustc_test_marker = "library/core/src/convert/mod.rs - convert::Into (line 398)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/convert/mod.rs - convert::Into (line 398)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/convert/mod.rs",
start_line: 398,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_247 {
fn main() {
struct Wrapper<T>(Vec<T>);
impl<T> Into<Vec<T>> for Wrapper<T> {
fn into(self) -> Vec<T> {
self.0
}
}
}
#[rustc_test_marker = "library/core/src/convert/mod.rs - convert::Into (line 410)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/convert/mod.rs - convert::Into (line 410)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/convert/mod.rs",
start_line: 410,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_248 {
fn main() {
fn is_hello<T: Into<Vec<u8>>>(s: T) {
let bytes = b"hello".to_vec();
assert_eq!(bytes, s.into());
}
let s = "hello".to_string();
is_hello(s);
}
#[rustc_test_marker = "library/core/src/convert/mod.rs - convert::Into (line 432)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/convert/mod.rs - convert::Into (line 432)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/convert/mod.rs",
start_line: 432,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_249 {
fn main() {
struct GreaterThanZero(i32);
impl TryFrom<i32> for GreaterThanZero {
type Error = &'static str;
fn try_from(value: i32) -> Result<Self, Self::Error> {
if value <= 0 {
Err("GreaterThanZero only accepts values greater than zero!")
} else {
Ok(GreaterThanZero(value))
}
}
}
}
#[rustc_test_marker = "library/core/src/convert/mod.rs - convert::TryFrom (line 639)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/convert/mod.rs - convert::TryFrom (line 639)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/convert/mod.rs",
start_line: 639,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_250 {
fn main() {
let big_number = 1_000_000_000_000i64;
// Silently truncates `big_number`, requires detecting
// and handling the truncation after the fact.
let smaller_number = big_number as i32;
assert_eq!(smaller_number, -727379968);
// Returns an error because `big_number` is too big to
// fit in an `i32`.
let try_smaller_number = i32::try_from(big_number);
assert!(try_smaller_number.is_err());
// Returns `Ok(3)`.
let try_successful_smaller_number = i32::try_from(3);
assert!(try_successful_smaller_number.is_ok());
}
#[rustc_test_marker = "library/core/src/convert/mod.rs - convert::TryFrom (line 659)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/convert/mod.rs - convert::TryFrom (line 659)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/convert/mod.rs",
start_line: 659,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_251 {
fn main() {
use std::convert::identity;
fn manipulation(x: u32) -> u32 {
// Let's pretend that adding one is an interesting function.
x + 1
}
let _arr = &[identity, manipulation];
}
#[rustc_test_marker = "library/core/src/convert/mod.rs - convert::identity (line 64)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/convert/mod.rs - convert::identity (line 64)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/convert/mod.rs",
start_line: 64,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_252 {
fn main() {
use std::convert::identity;
let condition = true;
fn manipulation(x: u32) -> u32 { x + 1 }
let do_stuff = if condition { manipulation } else { identity };
// Do more interesting stuff...
let _results = do_stuff(42);
}
#[rustc_test_marker = "library/core/src/convert/mod.rs - convert::identity (line 77)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/convert/mod.rs - convert::identity (line 77)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/convert/mod.rs",
start_line: 77,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_253 {
fn main() {
use std::convert::identity;
let iter = [Some(1), None, Some(3)].into_iter();
let filtered = iter.filter_map(identity).collect::<Vec<_>>();
assert_eq!(vec![1, 3], filtered);
}
#[rustc_test_marker = "library/core/src/convert/mod.rs - convert::identity (line 93)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/convert/mod.rs - convert::identity (line 93)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/convert/mod.rs",
start_line: 93,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_254 {
fn main() {
let x: f32 = false.into();
assert_eq!(x, 0.0);
assert!(x.is_sign_positive());
let y: f32 = true.into();
assert_eq!(y, 1.0);
}
#[rustc_test_marker = "library/core/src/convert/num.rs - convert::num::f32::from (line 205)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/convert/num.rs - convert::num::f32::from (line 205)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/convert/num.rs",
start_line: 205,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_255 {
fn main() {
let x: f64 = false.into();
assert_eq!(x, 0.0);
assert!(x.is_sign_positive());
let y: f64 = true.into();
assert_eq!(y, 1.0);
}
#[rustc_test_marker = "library/core/src/convert/num.rs - convert::num::f64::from (line 206)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/convert/num.rs - convert::num::f64::from (line 206)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/convert/num.rs",
start_line: 206,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_256 {
fn main() {
assert_eq!(i128::from(true), 1);
assert_eq!(i128::from(false), 0);
}
#[rustc_test_marker = "library/core/src/convert/num.rs - convert::num::i128::from (line 100)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/convert/num.rs - convert::num::i128::from (line 100)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/convert/num.rs",
start_line: 100,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_257 {
fn main() {
assert_eq!(i16::from(true), 1);
assert_eq!(i16::from(false), 0);
}
#[rustc_test_marker = "library/core/src/convert/num.rs - convert::num::i16::from (line 97)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/convert/num.rs - convert::num::i16::from (line 97)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/convert/num.rs",
start_line: 97,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_258 {
fn main() {
assert_eq!(i32::from(true), 1);
assert_eq!(i32::from(false), 0);
}
#[rustc_test_marker = "library/core/src/convert/num.rs - convert::num::i32::from (line 98)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/convert/num.rs - convert::num::i32::from (line 98)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/convert/num.rs",
start_line: 98,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_259 {
fn main() {
assert_eq!(i64::from(true), 1);
assert_eq!(i64::from(false), 0);
}
#[rustc_test_marker = "library/core/src/convert/num.rs - convert::num::i64::from (line 99)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/convert/num.rs - convert::num::i64::from (line 99)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/convert/num.rs",
start_line: 99,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_260 {
fn main() {
assert_eq!(i8::from(true), 1);
assert_eq!(i8::from(false), 0);
}
#[rustc_test_marker = "library/core/src/convert/num.rs - convert::num::i8::from (line 96)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/convert/num.rs - convert::num::i8::from (line 96)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/convert/num.rs",
start_line: 96,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_261 {
fn main() {
assert_eq!(isize::from(true), 1);
assert_eq!(isize::from(false), 0);
}
#[rustc_test_marker = "library/core/src/convert/num.rs - convert::num::isize::from (line 101)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/convert/num.rs - convert::num::isize::from (line 101)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/convert/num.rs",
start_line: 101,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_262 {
fn main() {
assert_eq!(u128::from(true), 1);
assert_eq!(u128::from(false), 0);
}
#[rustc_test_marker = "library/core/src/convert/num.rs - convert::num::u128::from (line 94)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/convert/num.rs - convert::num::u128::from (line 94)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/convert/num.rs",
start_line: 94,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_263 {
fn main() {
assert_eq!(u16::from(true), 1);
assert_eq!(u16::from(false), 0);
}
#[rustc_test_marker = "library/core/src/convert/num.rs - convert::num::u16::from (line 91)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/convert/num.rs - convert::num::u16::from (line 91)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/convert/num.rs",
start_line: 91,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_264 {
fn main() {
assert_eq!(u32::from(true), 1);
assert_eq!(u32::from(false), 0);
}
#[rustc_test_marker = "library/core/src/convert/num.rs - convert::num::u32::from (line 92)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/convert/num.rs - convert::num::u32::from (line 92)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/convert/num.rs",
start_line: 92,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_265 {
fn main() {
assert_eq!(u64::from(true), 1);
assert_eq!(u64::from(false), 0);
}
#[rustc_test_marker = "library/core/src/convert/num.rs - convert::num::u64::from (line 93)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/convert/num.rs - convert::num::u64::from (line 93)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/convert/num.rs",
start_line: 93,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_266 {
fn main() {
assert_eq!(u8::from(true), 1);
assert_eq!(u8::from(false), 0);
}
#[rustc_test_marker = "library/core/src/convert/num.rs - convert::num::u8::from (line 90)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/convert/num.rs - convert::num::u8::from (line 90)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/convert/num.rs",
start_line: 90,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_267 {
fn main() {
assert_eq!(usize::from(true), 1);
assert_eq!(usize::from(false), 0);
}
#[rustc_test_marker = "library/core/src/convert/num.rs - convert::num::usize::from (line 95)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/convert/num.rs - convert::num::usize::from (line 95)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/convert/num.rs",
start_line: 95,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_268 {
fn main() {
#[allow(dead_code)]
struct SomeOptions {
foo: i32,
bar: f32,
}
}
#[rustc_test_marker = "library/core/src/default.rs - default::Default (line 13)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/default.rs - default::Default (line 13)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/default.rs",
start_line: 13,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_269 {
#[allow(dead_code)]
#[derive(Default)]
struct SomeOptions {
foo: i32,
bar: f32,
}
fn main() {
let options: SomeOptions = Default::default();
}
#[rustc_test_marker = "library/core/src/default.rs - default::Default (line 23)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/default.rs - default::Default (line 23)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/default.rs",
start_line: 23,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_270 {
#[allow(dead_code)]
#[derive(Default)]
struct SomeOptions {
foo: i32,
bar: f32,
}
fn main() {
let options = SomeOptions { foo: 42, ..Default::default() };
}
#[rustc_test_marker = "library/core/src/default.rs - default::Default (line 40)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/default.rs - default::Default (line 40)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/default.rs",
start_line: 40,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_271 {
fn main() {
#[derive(Default)]
enum Kind {
#[default]
A,
B,
C,
}
}
#[rustc_test_marker = "library/core/src/default.rs - default::Default (line 62)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/default.rs - default::Default (line 62)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/default.rs",
start_line: 62,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_272 {
fn main() {
#![allow(dead_code)]
enum Kind {
A,
B,
C,
}
impl Default for Kind {
fn default() -> Self { Kind::A }
}
}
#[rustc_test_marker = "library/core/src/default.rs - default::Default (line 81)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/default.rs - default::Default (line 81)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/default.rs",
start_line: 81,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_273 {
fn main() {
#[allow(dead_code)]
#[derive(Default)]
struct SomeOptions {
foo: i32,
bar: f32,
}
}
#[rustc_test_marker = "library/core/src/default.rs - default::Default (line 96)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/default.rs - default::Default (line 96)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/default.rs",
start_line: 96,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_274 {
fn main() {
let i: i8 = Default::default();
let (x, y): (Option<String>, f64) = Default::default();
let (a, b, (c, d)): (i32, u32, (bool, bool)) = Default::default();
}
#[rustc_test_marker = "library/core/src/default.rs - default::Default::default (line 116)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/default.rs - default::Default::default (line 116)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/default.rs",
start_line: 116,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_275 {
fn main() {
#[allow(dead_code)]
enum Kind {
A,
B,
C,
}
impl Default for Kind {
fn default() -> Self { Kind::A }
}
}
#[rustc_test_marker = "library/core/src/default.rs - default::Default::default (line 124)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/default.rs - default::Default::default (line 124)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/default.rs",
start_line: 124,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_276 {
fn main() {
let path = std::env::var("IMPORTANT_PATH").unwrap();
}
#[rustc_test_marker = "library/core/src/error.rs - error (line 68)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/error.rs - error (line 68)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/error.rs",
start_line: 68,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::Yes,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_277 {
fn main() {
let path = std::env::var("IMPORTANT_PATH")
.expect("env variable `IMPORTANT_PATH` is not set");
}
#[rustc_test_marker = "library/core/src/error.rs - error (line 76)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/error.rs - error (line 76)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/error.rs",
start_line: 76,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::Yes,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_278 {
fn main() {
let path = std::env::var("IMPORTANT_PATH")
.expect("env variable `IMPORTANT_PATH` should be set by `wrapper_script.sh`");
}
#[rustc_test_marker = "library/core/src/error.rs - error (line 85)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/error.rs - error (line 85)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/error.rs",
start_line: 85,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::Yes,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_279 {
fn main() {
let err = "NaN".parse::<u32>().unwrap_err();
assert_eq!(err.to_string(), "invalid digit found in string");
}
#[rustc_test_marker = "library/core/src/error.rs - error::Error (line 17)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/error.rs - error::Error (line 17)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/error.rs",
start_line: 17,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_280 {
fn main() {
if let Err(e) = "xc".parse::<u32>() {
// Print `e` itself, no need for description().
eprintln!("Error: {e}");
}
}
#[rustc_test_marker = "library/core/src/error.rs - error::Error::description (line 102)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/error.rs - error::Error::description (line 102)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/error.rs",
start_line: 102,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_281 {
use std::error::Error;
use std::fmt;
#[derive(Debug)]
struct SuperError {
source: SuperErrorSideKick,
}
impl fmt::Display for SuperError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "SuperError is here!")
}
}
impl Error for SuperError {
fn source(&self) -> Option<&(dyn Error + 'static)> {
Some(&self.source)
}
}
#[derive(Debug)]
struct SuperErrorSideKick;
impl fmt::Display for SuperErrorSideKick {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "SuperErrorSideKick is here!")
}
}
impl Error for SuperErrorSideKick {}
fn get_super_error() -> Result<(), SuperError> {
Err(SuperError { source: SuperErrorSideKick })
}
fn main() {
match get_super_error() {
Err(e) => {
println!("Error: {e}");
println!("Caused by: {}", e.source().unwrap());
}
_ => println!("No error"),
}
}
#[rustc_test_marker = "library/core/src/error.rs - error::Error::source (line 37)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/error.rs - error::Error::source (line 37)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/error.rs",
start_line: 37,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_282 {
fn main() {
use std::ffi::CStr;
use std::os::raw::c_char;
/* Extern functions are awkward in doc comments - fake it instead
extern "C" { fn my_string() -> *const c_char; }
*/ unsafe extern "C" fn my_string() -> *const c_char { c"hello".as_ptr() }
unsafe {
let slice = CStr::from_ptr(my_string());
println!("string buffer size without nul terminator: {}", slice.to_bytes().len());
}
}
#[rustc_test_marker = "library/core/src/ffi/c_str.rs - ffi::c_str::CStr (line 45)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/ffi/c_str.rs - ffi::c_str::CStr (line 45)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/ffi/c_str.rs",
start_line: 45,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_283 {
fn main() {
use std::ffi::{CString, CStr};
use std::os::raw::c_char;
fn work(data: &CStr) {
/* Extern functions are awkward in doc comments - fake it instead
extern "C" { fn work_with(data: *const c_char); }
*/ unsafe extern "C" fn work_with(s: *const c_char) {}
unsafe { work_with(data.as_ptr()) }
}
let s = CString::new("data data data data").expect("CString::new failed");
work(&s);
}
#[rustc_test_marker = "library/core/src/ffi/c_str.rs - ffi::c_str::CStr (line 61)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/ffi/c_str.rs - ffi::c_str::CStr (line 61)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/ffi/c_str.rs",
start_line: 61,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_284 {
fn main() {
use std::ffi::CStr;
use std::os::raw::c_char;
/* Extern functions are awkward in doc comments - fake it instead
extern "C" { fn my_string() -> *const c_char; }
*/ unsafe extern "C" fn my_string() -> *const c_char { c"hello".as_ptr() }
fn my_string_safe() -> String {
let cstr = unsafe { CStr::from_ptr(my_string()) };
// Get copy-on-write Cow<'_, str>, then guarantee a freshly-owned String allocation
String::from_utf8_lossy(cstr.to_bytes()).to_string()
}
println!("string: {}", my_string_safe());
}
#[rustc_test_marker = "library/core/src/ffi/c_str.rs - ffi::c_str::CStr (line 79)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/ffi/c_str.rs - ffi::c_str::CStr (line 79)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/ffi/c_str.rs",
start_line: 79,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_285 {
fn main() {
#![allow(unused_must_use)] #![allow(temporary_cstring_as_ptr)]
use std::ffi::CString;
// Do not do this:
let ptr = CString::new("Hello").expect("CString::new failed").as_ptr();
unsafe {
// `ptr` is dangling
*ptr;
}
}
#[rustc_test_marker = "library/core/src/ffi/c_str.rs - ffi::c_str::CStr::as_ptr (line 473)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/ffi/c_str.rs - ffi::c_str::CStr::as_ptr (line 473)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/ffi/c_str.rs",
start_line: 473,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: true,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_286 {
fn main() {
#![allow(unused_must_use)]
use std::ffi::CString;
let hello = CString::new("Hello").expect("CString::new failed");
let ptr = hello.as_ptr();
unsafe {
// `ptr` is valid because `hello` is in scope
*ptr;
}
}
#[rustc_test_marker = "library/core/src/ffi/c_str.rs - ffi::c_str::CStr::as_ptr (line 491)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/ffi/c_str.rs - ffi::c_str::CStr::as_ptr (line 491)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/ffi/c_str.rs",
start_line: 491,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: true,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_287 {
fn main() {
use std::ffi::CStr;
let cstr = CStr::from_bytes_with_nul(b"foo\0").unwrap();
assert_eq!(cstr.count_bytes(), 3);
let cstr = CStr::from_bytes_with_nul(b"\0").unwrap();
assert_eq!(cstr.count_bytes(), 0);
}
#[rustc_test_marker = "library/core/src/ffi/c_str.rs - ffi::c_str::CStr::count_bytes (line 529)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/ffi/c_str.rs - ffi::c_str::CStr::count_bytes (line 529)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/ffi/c_str.rs",
start_line: 529,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_288 {
fn main() {
use std::ffi::CStr;
let mut buffer = [0u8; 16];
unsafe {
// Here we might call an unsafe C function that writes a string
// into the buffer.
let buf_ptr = buffer.as_mut_ptr();
buf_ptr.write_bytes(b'A', 8);
}
// Attempt to extract a C nul-terminated string from the buffer.
let c_str = CStr::from_bytes_until_nul(&buffer[..]).unwrap();
assert_eq!(c_str.to_str().unwrap(), "AAAAAAAA");
}
#[rustc_test_marker = "library/core/src/ffi/c_str.rs - ffi::c_str::CStr::from_bytes_until_nul (line 312)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/ffi/c_str.rs - ffi::c_str::CStr::from_bytes_until_nul (line 312)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/ffi/c_str.rs",
start_line: 312,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_289 {
fn main() {
use std::ffi::CStr;
let cstr = CStr::from_bytes_with_nul(b"hello\0");
assert!(cstr.is_ok());
}
#[rustc_test_marker = "library/core/src/ffi/c_str.rs - ffi::c_str::CStr::from_bytes_with_nul (line 356)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/ffi/c_str.rs - ffi::c_str::CStr::from_bytes_with_nul (line 356)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/ffi/c_str.rs",
start_line: 356,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_290 {
fn main() {
use std::ffi::CStr;
let cstr = CStr::from_bytes_with_nul(b"hello");
assert!(cstr.is_err());
}
#[rustc_test_marker = "library/core/src/ffi/c_str.rs - ffi::c_str::CStr::from_bytes_with_nul (line 365)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/ffi/c_str.rs - ffi::c_str::CStr::from_bytes_with_nul (line 365)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/ffi/c_str.rs",
start_line: 365,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_291 {
fn main() {
use std::ffi::CStr;
let cstr = CStr::from_bytes_with_nul(b"he\0llo\0");
assert!(cstr.is_err());
}
#[rustc_test_marker = "library/core/src/ffi/c_str.rs - ffi::c_str::CStr::from_bytes_with_nul (line 374)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/ffi/c_str.rs - ffi::c_str::CStr::from_bytes_with_nul (line 374)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/ffi/c_str.rs",
start_line: 374,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_292 {
fn main() {
use std::ffi::{CStr, CString};
unsafe {
let cstring = CString::new("hello").expect("CString::new failed");
let cstr = CStr::from_bytes_with_nul_unchecked(cstring.to_bytes_with_nul());
assert_eq!(cstr, &*cstring);
}
}
#[rustc_test_marker = "library/core/src/ffi/c_str.rs - ffi::c_str::CStr::from_bytes_with_nul_unchecked (line 406)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/ffi/c_str.rs - ffi::c_str::CStr::from_bytes_with_nul_unchecked (line 406)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/ffi/c_str.rs",
start_line: 406,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_293 {
fn main() {
use std::ffi::{c_char, CStr};
fn my_string() -> *const c_char {
c"hello".as_ptr()
}
unsafe {
let slice = CStr::from_ptr(my_string());
assert_eq!(slice.to_str().unwrap(), "hello");
}
}
#[rustc_test_marker = "library/core/src/ffi/c_str.rs - ffi::c_str::CStr::from_ptr (line 252)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/ffi/c_str.rs - ffi::c_str::CStr::from_ptr (line 252)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/ffi/c_str.rs",
start_line: 252,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_294 {
use std::ffi::CStr;
use std::ffi::FromBytesWithNulError;
fn main() { test().unwrap(); }
fn test() -> Result<(), FromBytesWithNulError> {
let cstr = CStr::from_bytes_with_nul(b"foo\0")?;
assert!(!cstr.is_empty());
let empty_cstr = CStr::from_bytes_with_nul(b"\0")?;
assert!(empty_cstr.is_empty());
assert!(c"".is_empty());
Ok(())
}
#[rustc_test_marker = "library/core/src/ffi/c_str.rs - ffi::c_str::CStr::is_empty (line 551)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/ffi/c_str.rs - ffi::c_str::CStr::is_empty (line 551)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/ffi/c_str.rs",
start_line: 551,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_295 {
fn main() {
use std::ffi::CStr;
let cstr = CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed");
assert_eq!(cstr.to_bytes(), b"foo");
}
#[rustc_test_marker = "library/core/src/ffi/c_str.rs - ffi::c_str::CStr::to_bytes (line 587)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/ffi/c_str.rs - ffi::c_str::CStr::to_bytes (line 587)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/ffi/c_str.rs",
start_line: 587,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_296 {
fn main() {
use std::ffi::CStr;
let cstr = CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed");
assert_eq!(cstr.to_bytes_with_nul(), b"foo\0");
}
#[rustc_test_marker = "library/core/src/ffi/c_str.rs - ffi::c_str::CStr::to_bytes_with_nul (line 616)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/ffi/c_str.rs - ffi::c_str::CStr::to_bytes_with_nul (line 616)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/ffi/c_str.rs",
start_line: 616,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_297 {
fn main() {
use std::ffi::CStr;
let cstr = CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed");
assert_eq!(cstr.to_str(), Ok("foo"));
}
#[rustc_test_marker = "library/core/src/ffi/c_str.rs - ffi::c_str::CStr::to_str (line 663)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/ffi/c_str.rs - ffi::c_str::CStr::to_str (line 663)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/ffi/c_str.rs",
start_line: 663,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_298 {
fn main() {
use std::ffi::{CStr, FromBytesWithNulError};
let _: FromBytesWithNulError = CStr::from_bytes_with_nul(b"f\0oo").unwrap_err();
}
#[rustc_test_marker = "library/core/src/ffi/c_str.rs - ffi::c_str::FromBytesWithNulError (line 126)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/ffi/c_str.rs - ffi::c_str::FromBytesWithNulError (line 126)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/ffi/c_str.rs",
start_line: 126,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_299 {
fn main() {
use std::fmt;
struct Foo(Vec<i32>);
impl fmt::Debug for Foo {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_list().entries(self.0.iter()).finish()
}
}
assert_eq!(
format!("{:?}", Foo(vec![10, 11])),
"[10, 11]",
);
}
#[rustc_test_marker = "library/core/src/fmt/builders.rs - fmt::builders::DebugList (line 594)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/builders.rs - fmt::builders::DebugList (line 594)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/builders.rs",
start_line: 594,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_300 {
fn main() {
use std::fmt;
struct Foo(Vec<i32>, Vec<u32>);
impl fmt::Debug for Foo {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_list()
.entries(self.0.iter())
.entries(self.1.iter())
.finish()
}
}
assert_eq!(
format!("{:?}", Foo(vec![10, 11], vec![12, 13])),
"[10, 11, 12, 13]",
);
}
#[rustc_test_marker = "library/core/src/fmt/builders.rs - fmt::builders::DebugList<'a,'b>::entries (line 669)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/builders.rs - fmt::builders::DebugList<'a,'b>::entries (line 669)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/builders.rs",
start_line: 669,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_301 {
fn main() {
use std::fmt;
struct Foo(Vec<i32>, Vec<u32>);
impl fmt::Debug for Foo {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_list()
.entry(&self.0) // We add the first "entry".
.entry(&self.1) // We add the second "entry".
.finish()
}
}
assert_eq!(
format!("{:?}", Foo(vec![10, 11], vec![12, 13])),
"[[10, 11], [12, 13]]",
);
}
#[rustc_test_marker = "library/core/src/fmt/builders.rs - fmt::builders::DebugList<'a,'b>::entry (line 627)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/builders.rs - fmt::builders::DebugList<'a,'b>::entry (line 627)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/builders.rs",
start_line: 627,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_302 {
fn main() {
use std::fmt;
struct Foo(Vec<i32>);
impl fmt::Debug for Foo {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_list()
.entries(self.0.iter())
.finish() // Ends the list formatting.
}
}
assert_eq!(
format!("{:?}", Foo(vec![10, 11])),
"[10, 11]",
);
}
#[rustc_test_marker = "library/core/src/fmt/builders.rs - fmt::builders::DebugList<'a,'b>::finish (line 704)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/builders.rs - fmt::builders::DebugList<'a,'b>::finish (line 704)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/builders.rs",
start_line: 704,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_303 {
fn main() {
use std::fmt;
struct Foo(Vec<(String, i32)>);
impl fmt::Debug for Foo {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_map().entries(self.0.iter().map(|&(ref k, ref v)| (k, v))).finish()
}
}
assert_eq!(
format!("{:?}", Foo(vec![("A".to_string(), 10), ("B".to_string(), 11)])),
"{\"A\": 10, \"B\": 11}",
);
}
#[rustc_test_marker = "library/core/src/fmt/builders.rs - fmt::builders::DebugMap (line 737)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/builders.rs - fmt::builders::DebugMap (line 737)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/builders.rs",
start_line: 737,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_304 {
fn main() {
use std::fmt;
struct Foo(Vec<(String, i32)>);
impl fmt::Debug for Foo {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_map()
// We map our vec so each entries' first field will become
// the "key".
.entries(self.0.iter().map(|&(ref k, ref v)| (k, v)))
.finish()
}
}
assert_eq!(
format!("{:?}", Foo(vec![("A".to_string(), 10), ("B".to_string(), 11)])),
"{\"A\": 10, \"B\": 11}",
);
}
#[rustc_test_marker = "library/core/src/fmt/builders.rs - fmt::builders::DebugMap<'a,'b>::entries (line 943)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/builders.rs - fmt::builders::DebugMap<'a,'b>::entries (line 943)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/builders.rs",
start_line: 943,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_305 {
fn main() {
use std::fmt;
struct Foo(Vec<(String, i32)>);
impl fmt::Debug for Foo {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_map()
.entry(&"whole", &self.0) // We add the "whole" entry.
.finish()
}
}
assert_eq!(
format!("{:?}", Foo(vec![("A".to_string(), 10), ("B".to_string(), 11)])),
"{\"whole\": [(\"A\", 10), (\"B\", 11)]}",
);
}
#[rustc_test_marker = "library/core/src/fmt/builders.rs - fmt::builders::DebugMap<'a,'b>::entry (line 775)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/builders.rs - fmt::builders::DebugMap<'a,'b>::entry (line 775)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/builders.rs",
start_line: 775,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_306 {
fn main() {
use std::fmt;
struct Foo(Vec<(String, i32)>);
impl fmt::Debug for Foo {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_map()
.entries(self.0.iter().map(|&(ref k, ref v)| (k, v)))
.finish() // Ends the map formatting.
}
}
assert_eq!(
format!("{:?}", Foo(vec![("A".to_string(), 10), ("B".to_string(), 11)])),
"{\"A\": 10, \"B\": 11}",
);
}
#[rustc_test_marker = "library/core/src/fmt/builders.rs - fmt::builders::DebugMap<'a,'b>::finish (line 985)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/builders.rs - fmt::builders::DebugMap<'a,'b>::finish (line 985)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/builders.rs",
start_line: 985,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_307 {
fn main() {
use std::fmt;
struct Foo(Vec<(String, i32)>);
impl fmt::Debug for Foo {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_map()
.key(&"whole").value(&self.0) // We add the "whole" entry.
.finish()
}
}
assert_eq!(
format!("{:?}", Foo(vec![("A".to_string(), 10), ("B".to_string(), 11)])),
"{\"whole\": [(\"A\", 10), (\"B\", 11)]}",
);
}
#[rustc_test_marker = "library/core/src/fmt/builders.rs - fmt::builders::DebugMap<'a,'b>::key (line 811)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/builders.rs - fmt::builders::DebugMap<'a,'b>::key (line 811)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/builders.rs",
start_line: 811,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_308 {
fn main() {
use std::fmt;
struct Foo(Vec<(String, i32)>);
impl fmt::Debug for Foo {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_map()
.key(&"whole").value(&self.0) // We add the "whole" entry.
.finish()
}
}
assert_eq!(
format!("{:?}", Foo(vec![("A".to_string(), 10), ("B".to_string(), 11)])),
"{\"whole\": [(\"A\", 10), (\"B\", 11)]}",
);
}
#[rustc_test_marker = "library/core/src/fmt/builders.rs - fmt::builders::DebugMap<'a,'b>::value (line 887)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/builders.rs - fmt::builders::DebugMap<'a,'b>::value (line 887)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/builders.rs",
start_line: 887,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_309 {
fn main() {
use std::fmt;
struct Foo(Vec<i32>);
impl fmt::Debug for Foo {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_set().entries(self.0.iter()).finish()
}
}
assert_eq!(
format!("{:?}", Foo(vec![10, 11])),
"{10, 11}",
);
}
#[rustc_test_marker = "library/core/src/fmt/builders.rs - fmt::builders::DebugSet (line 451)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/builders.rs - fmt::builders::DebugSet (line 451)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/builders.rs",
start_line: 451,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_310 {
fn main() {
use std::fmt;
struct Foo(Vec<i32>, Vec<u32>);
impl fmt::Debug for Foo {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_set()
.entries(self.0.iter()) // Adds the first "entry".
.entries(self.1.iter()) // Adds the second "entry".
.finish()
}
}
assert_eq!(
format!("{:?}", Foo(vec![10, 11], vec![12, 13])),
"{10, 11, 12, 13}",
);
}
#[rustc_test_marker = "library/core/src/fmt/builders.rs - fmt::builders::DebugSet<'a,'b>::entries (line 526)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/builders.rs - fmt::builders::DebugSet<'a,'b>::entries (line 526)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/builders.rs",
start_line: 526,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_311 {
fn main() {
use std::fmt;
struct Foo(Vec<i32>, Vec<u32>);
impl fmt::Debug for Foo {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_set()
.entry(&self.0) // Adds the first "entry".
.entry(&self.1) // Adds the second "entry".
.finish()
}
}
assert_eq!(
format!("{:?}", Foo(vec![10, 11], vec![12, 13])),
"{[10, 11], [12, 13]}",
);
}
#[rustc_test_marker = "library/core/src/fmt/builders.rs - fmt::builders::DebugSet<'a,'b>::entry (line 484)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/builders.rs - fmt::builders::DebugSet<'a,'b>::entry (line 484)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/builders.rs",
start_line: 484,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_312 {
fn main() {
use std::fmt;
struct Foo(Vec<i32>);
impl fmt::Debug for Foo {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_set()
.entries(self.0.iter())
.finish() // Ends the set formatting.
}
}
assert_eq!(
format!("{:?}", Foo(vec![10, 11])),
"{10, 11}",
);
}
#[rustc_test_marker = "library/core/src/fmt/builders.rs - fmt::builders::DebugSet<'a,'b>::finish (line 561)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/builders.rs - fmt::builders::DebugSet<'a,'b>::finish (line 561)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/builders.rs",
start_line: 561,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_313 {
fn main() {
use std::fmt;
struct Foo {
bar: i32,
baz: String,
}
impl fmt::Debug for Foo {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Foo")
.field("bar", &self.bar)
.field("baz", &self.baz)
.finish()
}
}
assert_eq!(
format!("{:?}", Foo { bar: 10, baz: "Hello World".to_string() }),
"Foo { bar: 10, baz: \"Hello World\" }",
);
}
#[rustc_test_marker = "library/core/src/fmt/builders.rs - fmt::builders::DebugStruct (line 62)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/builders.rs - fmt::builders::DebugStruct (line 62)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/builders.rs",
start_line: 62,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_314 {
fn main() {
use std::fmt;
struct Bar {
bar: i32,
another: String,
}
impl fmt::Debug for Bar {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Bar")
.field("bar", &self.bar) // We add `bar` field.
.field("another", &self.another) // We add `another` field.
// We even add a field which doesn't exist (because why not?).
.field("nonexistent_field", &1)
.finish() // We're good to go!
}
}
assert_eq!(
format!("{:?}", Bar { bar: 10, another: "Hello World".to_string() }),
"Bar { bar: 10, another: \"Hello World\", nonexistent_field: 1 }",
);
}
#[rustc_test_marker = "library/core/src/fmt/builders.rs - fmt::builders::DebugStruct<'a,'b>::field (line 107)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/builders.rs - fmt::builders::DebugStruct<'a,'b>::field (line 107)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/builders.rs",
start_line: 107,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_315 {
fn main() {
use std::fmt;
struct Bar {
bar: i32,
baz: String,
}
impl fmt::Debug for Bar {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Bar")
.field("bar", &self.bar)
.field("baz", &self.baz)
.finish() // You need to call it to "finish" the
// struct formatting.
}
}
assert_eq!(
format!("{:?}", Bar { bar: 10, baz: "Hello World".to_string() }),
"Bar { bar: 10, baz: \"Hello World\" }",
);
}
#[rustc_test_marker = "library/core/src/fmt/builders.rs - fmt::builders::DebugStruct<'a,'b>::finish (line 220)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/builders.rs - fmt::builders::DebugStruct<'a,'b>::finish (line 220)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/builders.rs",
start_line: 220,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_316 {
fn main() {
use std::fmt;
struct Bar {
bar: i32,
hidden: f32,
}
impl fmt::Debug for Bar {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Bar")
.field("bar", &self.bar)
.finish_non_exhaustive() // Show that some other field(s) exist.
}
}
assert_eq!(
format!("{:?}", Bar { bar: 10, hidden: 1.0 }),
"Bar { bar: 10, .. }",
);
}
#[rustc_test_marker = "library/core/src/fmt/builders.rs - fmt::builders::DebugStruct<'a,'b>::finish_non_exhaustive (line 175)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/builders.rs - fmt::builders::DebugStruct<'a,'b>::finish_non_exhaustive (line 175)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/builders.rs",
start_line: 175,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_317 {
fn main() {
use std::fmt;
struct Foo(i32, String);
impl fmt::Debug for Foo {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_tuple("Foo")
.field(&self.0)
.field(&self.1)
.finish()
}
}
assert_eq!(
format!("{:?}", Foo(10, "Hello World".to_string())),
"Foo(10, \"Hello World\")",
);
}
#[rustc_test_marker = "library/core/src/fmt/builders.rs - fmt::builders::DebugTuple (line 267)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/builders.rs - fmt::builders::DebugTuple (line 267)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/builders.rs",
start_line: 267,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_318 {
fn main() {
use std::fmt;
struct Foo(i32, String);
impl fmt::Debug for Foo {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_tuple("Foo")
.field(&self.0) // We add the first field.
.field(&self.1) // We add the second field.
.finish() // We're good to go!
}
}
assert_eq!(
format!("{:?}", Foo(10, "Hello World".to_string())),
"Foo(10, \"Hello World\")",
);
}
#[rustc_test_marker = "library/core/src/fmt/builders.rs - fmt::builders::DebugTuple<'a,'b>::field (line 309)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/builders.rs - fmt::builders::DebugTuple<'a,'b>::field (line 309)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/builders.rs",
start_line: 309,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_319 {
fn main() {
use std::fmt;
struct Foo(i32, String);
impl fmt::Debug for Foo {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_tuple("Foo")
.field(&self.0)
.field(&self.1)
.finish() // You need to call it to "finish" the
// tuple formatting.
}
}
assert_eq!(
format!("{:?}", Foo(10, "Hello World".to_string())),
"Foo(10, \"Hello World\")",
);
}
#[rustc_test_marker = "library/core/src/fmt/builders.rs - fmt::builders::DebugTuple<'a,'b>::finish (line 367)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/builders.rs - fmt::builders::DebugTuple<'a,'b>::finish (line 367)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/builders.rs",
start_line: 367,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_320 {
fn main() {
let debug = format!("{:?}", format_args!("{} foo {:?}", 1, 2));
let display = format!("{}", format_args!("{} foo {:?}", 1, 2));
assert_eq!("1 foo 2", display);
assert_eq!(display, debug);
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Arguments (line 312)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Arguments (line 312)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 312,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_321 {
fn main() {
use std::fmt::Arguments;
fn write_str(_: &str) { /* ... */ }
fn write_fmt(args: &Arguments<'_>) {
if let Some(s) = args.as_str() {
write_str(s)
} else {
write_str(&args.to_string());
}
}
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Arguments<'a>::as_str (line 422)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Arguments<'a>::as_str (line 422)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 422,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_322 {
fn main() {
assert_eq!(format_args!("hello").as_str(), Some("hello"));
assert_eq!(format_args!("").as_str(), Some(""));
assert_eq!(format_args!("{:?}", std::env::current_dir()).as_str(), None);
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Arguments<'a>::as_str (line 436)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Arguments<'a>::as_str (line 436)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 436,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_323 {
fn main() {
let x = 42; // 42 is '101010' in binary
assert_eq!(format!("{x:b}"), "101010");
assert_eq!(format!("{x:#b}"), "0b101010");
assert_eq!(format!("{:b}", -16), "11111111111111111111111111110000");
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Binary (line 813)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Binary (line 813)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 813,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_324 {
fn main() {
use std::fmt;
struct Length(i32);
impl fmt::Binary for Length {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let val = self.0;
fmt::Binary::fmt(&val, f) // delegate to i32's implementation
}
}
let l = Length(107);
assert_eq!(format!("l as binary is: {l:b}"), "l as binary is: 1101011");
assert_eq!(
// Note that the `0b` prefix added by `#` is included in the total width, so we
// need to add two to correctly display all 32 bits.
format!("l as binary is: {l:#034b}"),
"l as binary is: 0b00000000000000000000000001101011"
);
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Binary (line 824)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Binary (line 824)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 824,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_325 {
fn main() {
#[derive(Debug)]
struct Point {
x: i32,
y: i32,
}
let origin = Point { x: 0, y: 0 };
assert_eq!(format!("The origin is: {origin:?}"), "The origin is: Point { x: 0, y: 0 }");
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Debug (line 505)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Debug (line 505)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 505,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_326 {
fn main() {
use std::fmt;
struct Point {
x: i32,
y: i32,
}
impl fmt::Debug for Point {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Point")
.field("x", &self.x)
.field("y", &self.y)
.finish()
}
}
let origin = Point { x: 0, y: 0 };
assert_eq!(format!("The origin is: {origin:?}"), "The origin is: Point { x: 0, y: 0 }");
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Debug (line 519)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Debug (line 519)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 519,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_327 {
fn main() {
use std::fmt;
struct Point {
x: i32,
y: i32,
}
impl fmt::Debug for Point {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Point [{} {}]", self.x, self.y)
}
}
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Debug (line 551)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Debug (line 551)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 551,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_328 {
fn main() {
#[derive(Debug)]
struct Point {
x: i32,
y: i32,
}
let origin = Point { x: 0, y: 0 };
assert_eq!(format!("The origin is: {origin:#?}"),
"The origin is: Point {
x: 0,
y: 0,
}");
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Debug (line 570)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Debug (line 570)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 570,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_329 {
fn main() {
use std::fmt;
struct Position {
longitude: f32,
latitude: f32,
}
impl fmt::Debug for Position {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("")
.field(&self.longitude)
.field(&self.latitude)
.finish()
}
}
let position = Position { longitude: 1.987, latitude: 2.983 };
assert_eq!(format!("{position:?}"), "(1.987, 2.983)");
assert_eq!(format!("{position:#?}"), "(
1.987,
2.983,
)");
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Debug::fmt (line 611)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Debug::fmt (line 611)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 611,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_330 {
fn main() {
use std::fmt;
struct Point {
x: i32,
y: i32,
}
impl fmt::Display for Point {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "({}, {})", self.x, self.y)
}
}
let origin = Point { x: 0, y: 0 };
assert_eq!(format!("The origin is: {origin}"), "The origin is: (0, 0)");
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Display (line 684)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Display (line 684)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 684,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_331 {
fn main() {
use std::fmt;
struct Position {
longitude: f32,
latitude: f32,
}
impl fmt::Display for Position {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "({}, {})", self.longitude, self.latitude)
}
}
assert_eq!("(1.987, 2.983)",
format!("{}", Position { longitude: 1.987, latitude: 2.983, }));
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Display::fmt (line 728)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Display::fmt (line 728)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 728,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_332 {
fn main() {
use std::fmt::{self, write};
let mut output = String::new();
if let Err(fmt::Error) = write(&mut output, format_args!("Hello {}!", "world")) {
panic!("An error occurred");
}
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Error (line 97)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Error (line 97)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 97,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_333 {
fn main() {
use std::fmt::{self, Alignment};
struct Foo;
impl fmt::Display for Foo {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
let s = if let Some(s) = formatter.align() {
match s {
Alignment::Left => "left",
Alignment::Right => "right",
Alignment::Center => "center",
}
} else {
"into the void"
};
write!(formatter, "{s}")
}
}
assert_eq!(format!("{Foo:<}"), "left");
assert_eq!(format!("{Foo:>}"), "right");
assert_eq!(format!("{Foo:^}"), "center");
assert_eq!(format!("{Foo}"), "into the void");
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Formatter<'a>::align (line 1693)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Formatter<'a>::align (line 1693)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 1693,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_334 {
fn main() {
use std::fmt;
struct Foo(i32);
impl fmt::Display for Foo {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
if formatter.alternate() {
write!(formatter, "Foo({})", self.0)
} else {
write!(formatter, "{}", self.0)
}
}
}
assert_eq!(format!("{:#}", Foo(23)), "Foo(23)");
assert_eq!(format!("{}", Foo(23)), "23");
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Formatter<'a>::alternate (line 1855)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Formatter<'a>::alternate (line 1855)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 1855,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_335 {
fn main() {
use std::fmt;
struct Foo(Vec<i32>);
impl fmt::Debug for Foo {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_list().entries(self.0.iter()).finish()
}
}
assert_eq!(format!("{:?}", Foo(vec![10, 11])), "[10, 11]");
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Formatter<'a>::debug_list (line 2217)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Formatter<'a>::debug_list (line 2217)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 2217,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_336 {
fn main() {
use std::fmt;
struct Foo(Vec<(String, i32)>);
impl fmt::Debug for Foo {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_map().entries(self.0.iter().map(|&(ref k, ref v)| (k, v))).finish()
}
}
assert_eq!(
format!("{:?}", Foo(vec![("A".to_string(), 10), ("B".to_string(), 11)])),
r#"{"A": 10, "B": 11}"#
);
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Formatter<'a>::debug_map (line 2298)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Formatter<'a>::debug_map (line 2298)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 2298,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_337 {
fn main() {
use std::fmt;
struct Foo(Vec<i32>);
impl fmt::Debug for Foo {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_set().entries(self.0.iter()).finish()
}
}
assert_eq!(format!("{:?}", Foo(vec![10, 11])), "{10, 11}");
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Formatter<'a>::debug_set (line 2240)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Formatter<'a>::debug_set (line 2240)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 2240,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_338 {
fn main() {
use std::fmt;
struct Arm<'a, L, R>(&'a (L, R));
struct Table<'a, K, V>(&'a [(K, V)], V);
impl<'a, L, R> fmt::Debug for Arm<'a, L, R>
where
L: 'a + fmt::Debug, R: 'a + fmt::Debug
{
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
L::fmt(&(self.0).0, fmt)?;
fmt.write_str(" => ")?;
R::fmt(&(self.0).1, fmt)
}
}
impl<'a, K, V> fmt::Debug for Table<'a, K, V>
where
K: 'a + fmt::Debug, V: 'a + fmt::Debug
{
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_set()
.entries(self.0.iter().map(Arm))
.entry(&Arm(&(format_args!("_"), &self.1)))
.finish()
}
}
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Formatter<'a>::debug_set (line 2259)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Formatter<'a>::debug_set (line 2259)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 2259,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_339 {
fn main() {
use std::fmt;
use std::net::Ipv4Addr;
struct Foo {
bar: i32,
baz: String,
addr: Ipv4Addr,
}
impl fmt::Debug for Foo {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Foo")
.field("bar", &self.bar)
.field("baz", &self.baz)
.field("addr", &format_args!("{}", self.addr))
.finish()
}
}
assert_eq!(
"Foo { bar: 10, baz: \"Hello World\", addr: 127.0.0.1 }",
format!("{:?}", Foo {
bar: 10,
baz: "Hello World".to_string(),
addr: Ipv4Addr::new(127, 0, 0, 1),
})
);
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Formatter<'a>::debug_struct (line 1922)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Formatter<'a>::debug_struct (line 1922)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 1922,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_340 {
fn main() {
use std::fmt;
use std::marker::PhantomData;
struct Foo<T>(i32, String, PhantomData<T>);
impl<T> fmt::Debug for Foo<T> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_tuple("Foo")
.field(&self.0)
.field(&self.1)
.field(&format_args!("_"))
.finish()
}
}
assert_eq!(
"Foo(10, \"Hello\", _)",
format!("{:?}", Foo(10, "Hello".to_string(), PhantomData::<u8>))
);
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Formatter<'a>::debug_tuple (line 2084)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Formatter<'a>::debug_tuple (line 2084)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 2084,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_341 {
fn main() {
use std::fmt;
struct Foo;
impl fmt::Display for Foo {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
let c = formatter.fill();
if let Some(width) = formatter.width() {
for _ in 0..width {
write!(formatter, "{c}")?;
}
Ok(())
} else {
write!(formatter, "{c}")
}
}
}
// We set alignment to the right with ">".
assert_eq!(format!("{Foo:G>3}"), "GGG");
assert_eq!(format!("{Foo:t>6}"), "tttttt");
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Formatter<'a>::fill (line 1660)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Formatter<'a>::fill (line 1660)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 1660,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_342 {
fn main() {
use std::fmt;
struct Foo;
impl fmt::Display for Foo {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.pad("Foo")
}
}
assert_eq!(format!("{Foo:<4}"), "Foo ");
assert_eq!(format!("{Foo:0>4}"), "0Foo");
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Formatter<'a>::pad (line 1401)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Formatter<'a>::pad (line 1401)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 1401,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_343 {
fn main() {
use std::fmt;
struct Foo { nb: i32 }
impl Foo {
fn new(nb: i32) -> Foo {
Foo {
nb,
}
}
}
impl fmt::Display for Foo {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
// We need to remove "-" from the number output.
let tmp = self.nb.abs().to_string();
formatter.pad_integral(self.nb >= 0, "Foo ", &tmp)
}
}
assert_eq!(format!("{}", Foo::new(2)), "2");
assert_eq!(format!("{}", Foo::new(-1)), "-1");
assert_eq!(format!("{}", Foo::new(0)), "0");
assert_eq!(format!("{:#}", Foo::new(-1)), "-Foo 1");
assert_eq!(format!("{:0>#8}", Foo::new(-1)), "00-Foo 1");
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Formatter<'a>::pad_integral (line 1293)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Formatter<'a>::pad_integral (line 1293)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 1293,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_344 {
fn main() {
use std::fmt;
struct Foo(f32);
impl fmt::Display for Foo {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
if let Some(precision) = formatter.precision() {
// If we received a precision, we use it.
write!(formatter, "Foo({1:.*})", precision, self.0)
} else {
// Otherwise we default to 2.
write!(formatter, "Foo({:.2})", self.0)
}
}
}
assert_eq!(format!("{:.4}", Foo(23.2)), "Foo(23.2000)");
assert_eq!(format!("{}", Foo(23.2)), "Foo(23.20)");
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Formatter<'a>::precision (line 1764)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Formatter<'a>::precision (line 1764)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 1764,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_345 {
fn main() {
use std::fmt;
struct Foo(i32);
impl fmt::Display for Foo {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
assert!(formatter.sign_aware_zero_pad());
assert_eq!(formatter.width(), Some(4));
// We ignore the formatter's options.
write!(formatter, "{}", self.0)
}
}
assert_eq!(format!("{:04}", Foo(23)), "23");
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Formatter<'a>::sign_aware_zero_pad (line 1883)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Formatter<'a>::sign_aware_zero_pad (line 1883)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 1883,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_346 {
fn main() {
use std::fmt;
struct Foo(i32);
impl fmt::Display for Foo {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
if formatter.sign_minus() {
// You want a minus sign? Have one!
write!(formatter, "-Foo({})", self.0)
} else {
write!(formatter, "Foo({})", self.0)
}
}
}
assert_eq!(format!("{:-}", Foo(23)), "-Foo(23)");
assert_eq!(format!("{}", Foo(23)), "Foo(23)");
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Formatter<'a>::sign_minus (line 1826)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Formatter<'a>::sign_minus (line 1826)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 1826,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_347 {
fn main() {
use std::fmt;
struct Foo(i32);
impl fmt::Display for Foo {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
if formatter.sign_plus() {
write!(formatter,
"Foo({}{})",
if self.0 < 0 { '-' } else { '+' },
self.0.abs())
} else {
write!(formatter, "Foo({})", self.0)
}
}
}
assert_eq!(format!("{:+}", Foo(23)), "Foo(+23)");
assert_eq!(format!("{:+}", Foo(-23)), "Foo(-23)");
assert_eq!(format!("{}", Foo(23)), "Foo(23)");
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Formatter<'a>::sign_plus (line 1794)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Formatter<'a>::sign_plus (line 1794)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 1794,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_348 {
fn main() {
use std::fmt;
struct Foo(i32);
impl fmt::Display for Foo {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
if let Some(width) = formatter.width() {
// If we received a width, we use it
write!(formatter, "{:width$}", format!("Foo({})", self.0), width = width)
} else {
// Otherwise we do nothing special
write!(formatter, "Foo({})", self.0)
}
}
}
assert_eq!(format!("{:10}", Foo(23)), "Foo(23) ");
assert_eq!(format!("{}", Foo(23)), "Foo(23)");
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Formatter<'a>::width (line 1733)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Formatter<'a>::width (line 1733)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 1733,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_349 {
fn main() {
use std::fmt;
struct Foo(i32);
impl fmt::Display for Foo {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_fmt(format_args!("Foo {}", self.0))
}
}
assert_eq!(format!("{}", Foo(-1)), "Foo -1");
assert_eq!(format!("{:0>8}", Foo(2)), "Foo 2");
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Formatter<'a>::write_fmt (line 1620)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Formatter<'a>::write_fmt (line 1620)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 1620,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_350 {
fn main() {
use std::fmt;
struct Foo;
impl fmt::Display for Foo {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str("Foo")
// This is equivalent to:
// write!(formatter, "Foo")
}
}
assert_eq!(format!("{Foo}"), "Foo");
assert_eq!(format!("{Foo:0>8}"), "Foo");
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Formatter<'a>::write_str (line 1595)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Formatter<'a>::write_str (line 1595)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 1595,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_351 {
fn main() {
let x = 42.0; // 42.0 is '4.2e1' in scientific notation
assert_eq!(format!("{x:e}"), "4.2e1");
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::LowerExp (line 1028)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::LowerExp (line 1028)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 1028,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_352 {
fn main() {
use std::fmt;
struct Length(i32);
impl fmt::LowerExp for Length {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let val = f64::from(self.0);
fmt::LowerExp::fmt(&val, f) // delegate to f64's implementation
}
}
let l = Length(100);
assert_eq!(
format!("l in scientific notation is: {l:e}"),
"l in scientific notation is: 1e2"
);
assert_eq!(
format!("l in scientific notation is: {l:05e}"),
"l in scientific notation is: 001e2"
);
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::LowerExp (line 1036)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::LowerExp (line 1036)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 1036,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_353 {
fn main() {
let y = 42; // 42 is '2a' in hex
assert_eq!(format!("{y:x}"), "2a");
assert_eq!(format!("{y:#x}"), "0x2a");
assert_eq!(format!("{:x}", -16), "fffffff0");
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::LowerHex (line 873)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::LowerHex (line 873)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 873,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_354 {
fn main() {
use std::fmt;
struct Length(i32);
impl fmt::LowerHex for Length {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let val = self.0;
fmt::LowerHex::fmt(&val, f) // delegate to i32's implementation
}
}
let l = Length(9);
assert_eq!(format!("l as hex is: {l:x}"), "l as hex is: 9");
assert_eq!(format!("l as hex is: {l:#010x}"), "l as hex is: 0x00000009");
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::LowerHex (line 884)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::LowerHex (line 884)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 884,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_355 {
fn main() {
let x = 42; // 42 is '52' in octal
assert_eq!(format!("{x:o}"), "52");
assert_eq!(format!("{x:#o}"), "0o52");
assert_eq!(format!("{:o}", -16), "37777777760");
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Octal (line 759)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Octal (line 759)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 759,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_356 {
fn main() {
use std::fmt;
struct Length(i32);
impl fmt::Octal for Length {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let val = self.0;
fmt::Octal::fmt(&val, f) // delegate to i32's implementation
}
}
let l = Length(9);
assert_eq!(format!("l as octal is: {l:o}"), "l as octal is: 11");
assert_eq!(format!("l as octal is: {l:#06o}"), "l as octal is: 0o0011");
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Octal (line 770)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Octal (line 770)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 770,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_357 {
fn main() {
let x = &42;
let address = format!("{x:p}"); // this produces something like '0x7f06092ac6d0'
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Pointer (line 978)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Pointer (line 978)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 978,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_358 {
fn main() {
use std::fmt;
struct Length(i32);
impl fmt::Pointer for Length {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// use `as` to convert to a `*const T`, which implements Pointer, which we can use
let ptr = self as *const Self;
fmt::Pointer::fmt(&ptr, f)
}
}
let l = Length(42);
println!("l is in memory here: {l:p}");
let l_ptr = format!("{l:018p}");
assert_eq!(l_ptr.len(), 18);
assert_eq!(&l_ptr[..2], "0x");
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Pointer (line 986)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Pointer (line 986)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 986,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_359 {
fn main() {
use std::fmt;
#[derive(Debug)]
struct Triangle {
a: f32,
b: f32,
c: f32
}
impl fmt::Display for Triangle {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "({}, {}, {})", self.a, self.b, self.c)
}
}
let pythagorean_triple = Triangle { a: 3.0, b: 4.0, c: 5.0 };
assert_eq!(format!("{pythagorean_triple}"), "(3, 4, 5)");
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Result (line 49)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Result (line 49)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 49,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_360 {
fn main() {
let x = 42.0; // 42.0 is '4.2E1' in scientific notation
assert_eq!(format!("{x:E}"), "4.2E1");
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::UpperExp (line 1079)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::UpperExp (line 1079)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 1079,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_361 {
fn main() {
use std::fmt;
struct Length(i32);
impl fmt::UpperExp for Length {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let val = f64::from(self.0);
fmt::UpperExp::fmt(&val, f) // delegate to f64's implementation
}
}
let l = Length(100);
assert_eq!(
format!("l in scientific notation is: {l:E}"),
"l in scientific notation is: 1E2"
);
assert_eq!(
format!("l in scientific notation is: {l:05E}"),
"l in scientific notation is: 001E2"
);
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::UpperExp (line 1087)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::UpperExp (line 1087)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 1087,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_362 {
fn main() {
let y = 42; // 42 is '2A' in hex
assert_eq!(format!("{y:X}"), "2A");
assert_eq!(format!("{y:#X}"), "0x2A");
assert_eq!(format!("{:X}", -16), "FFFFFFF0");
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::UpperHex (line 928)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::UpperHex (line 928)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 928,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_363 {
fn main() {
use std::fmt;
struct Length(i32);
impl fmt::UpperHex for Length {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let val = self.0;
fmt::UpperHex::fmt(&val, f) // delegate to i32's implementation
}
}
let l = Length(i32::MAX);
assert_eq!(format!("l as hex is: {l:X}"), "l as hex is: 7FFFFFFF");
assert_eq!(format!("l as hex is: {l:#010X}"), "l as hex is: 0x7FFFFFFF");
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::UpperHex (line 939)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::UpperHex (line 939)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 939,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_364 {
fn main() {
use std::fmt::{Error, Write};
fn writer<W: Write>(f: &mut W, c: char) -> Result<(), Error> {
f.write_char(c)
}
let mut buf = String::new();
writer(&mut buf, 'a').unwrap();
writer(&mut buf, 'b').unwrap();
assert_eq!(&buf, "ab");
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Write::write_char (line 165)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Write::write_char (line 165)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 165,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_365 {
fn main() {
use std::fmt::{Error, Write};
fn writer<W: Write>(f: &mut W, s: &str) -> Result<(), Error> {
f.write_fmt(format_args!("{s}"))
}
let mut buf = String::new();
writer(&mut buf, "world").unwrap();
assert_eq!(&buf, "world");
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Write::write_fmt (line 194)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Write::write_fmt (line 194)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 194,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_366 {
fn main() {
use std::fmt::{Error, Write};
fn writer<W: Write>(f: &mut W, s: &str) -> Result<(), Error> {
f.write_str(s)
}
let mut buf = String::new();
writer(&mut buf, "hola").unwrap();
assert_eq!(&buf, "hola");
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::Write::write_str (line 138)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::Write::write_str (line 138)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 138,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_367 {
fn main() {
use std::fmt;
let mut output = String::new();
fmt::write(&mut output, format_args!("Hello {}!", "world"))
.expect("Error occurred while trying to write in String");
assert_eq!(output, "Hello world!");
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::write (line 1128)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::write (line 1128)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 1128,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_368 {
fn main() {
use std::fmt::Write;
let mut output = String::new();
write!(&mut output, "Hello {}!", "world")
.expect("Error occurred while trying to write in String");
assert_eq!(output, "Hello world!");
}
#[rustc_test_marker = "library/core/src/fmt/mod.rs - fmt::write (line 1139)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/fmt/mod.rs - fmt::write (line 1139)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/fmt/mod.rs",
start_line: 1139,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_369 {
fn main() {
use std::future::IntoFuture;
async fn foo() {
let v = async { "meow" };
let mut fut = v.into_future();
assert_eq!("meow", fut.await);
}
}
#[rustc_test_marker = "library/core/src/future/into_future.rs - future::into_future::IntoFuture (line 15)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/future/into_future.rs - future::into_future::IntoFuture (line 15)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/future/into_future.rs",
start_line: 15,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: true,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_370 {
fn main() {
use std::future::{ready, Ready, IntoFuture};
/// Eventually multiply two numbers
pub struct Multiply {
num: u16,
factor: u16,
}
impl Multiply {
/// Construct a new instance of `Multiply`.
pub fn new(num: u16, factor: u16) -> Self {
Self { num, factor }
}
/// Set the number to multiply by the factor.
pub fn number(mut self, num: u16) -> Self {
self.num = num;
self
}
/// Set the factor to multiply the number with.
pub fn factor(mut self, factor: u16) -> Self {
self.factor = factor;
self
}
}
impl IntoFuture for Multiply {
type Output = u16;
type IntoFuture = Ready<Self::Output>;
fn into_future(self) -> Self::IntoFuture {
ready(self.num * self.factor)
}
}
// NOTE: Rust does not yet have an `async fn main` function, that functionality
// currently only exists in the ecosystem.
async fn run() {
let num = Multiply::new(0, 0) // initialize the builder to number: 0, factor: 0
.number(2) // change the number to 2
.factor(2) // change the factor to 2
.await; // convert to future and .await
assert_eq!(num, 4);
}
}
#[rustc_test_marker = "library/core/src/future/into_future.rs - future::into_future::IntoFuture (line 33)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/future/into_future.rs - future::into_future::IntoFuture (line 33)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/future/into_future.rs",
start_line: 33,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_371 {
fn main() {
use std::future::IntoFuture;
/// Convert the output of a future to a string.
async fn fut_to_string<Fut>(fut: Fut) -> String
where
Fut: IntoFuture,
Fut::Output: std::fmt::Debug,
{
format!("{:?}", fut.await)
}
}
#[rustc_test_marker = "library/core/src/future/into_future.rs - future::into_future::IntoFuture (line 89)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/future/into_future.rs - future::into_future::IntoFuture (line 89)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/future/into_future.rs",
start_line: 89,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_372 {
fn main() {
use std::future::IntoFuture;
async fn foo() {
let v = async { "meow" };
let mut fut = v.into_future();
assert_eq!("meow", fut.await);
}
}
#[rustc_test_marker = "library/core/src/future/into_future.rs - future::into_future::IntoFuture::into_future (line 123)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/future/into_future.rs - future::into_future::IntoFuture::into_future (line 123)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/future/into_future.rs",
start_line: 123,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: true,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_373 {
fn main() {
use std::future;
async fn run() {
let future = future::pending();
let () = future.await;
unreachable!();
}
}
#[rustc_test_marker = "library/core/src/future/pending.rs - future::pending::pending (line 23)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/future/pending.rs - future::pending::pending (line 23)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/future/pending.rs",
start_line: 23,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: true,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_374 {
fn main() {
async fn run() {
use core::future::poll_fn;
use std::task::{Context, Poll};
fn read_line(_cx: &mut Context<'_>) -> Poll<String> {
Poll::Ready("Hello, World!".into())
}
let read_future = poll_fn(read_line);
assert_eq!(read_future.await, "Hello, World!".to_owned());
}
}
#[rustc_test_marker = "library/core/src/future/poll_fn.rs - future::poll_fn::poll_fn (line 14)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/future/poll_fn.rs - future::poll_fn::poll_fn (line 14)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/future/poll_fn.rs",
start_line: 14,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_375 {
fn main() {
async fn run() {
use core::future::{self, Future};
use core::task::Poll;
/// Resolves to the first future that completes. In the event of a tie, `a` wins.
fn naive_select<T>(
a: impl Future<Output = T>,
b: impl Future<Output = T>,
) -> impl Future<Output = T>
{
let (mut a, mut b) = (Box::pin(a), Box::pin(b));
future::poll_fn(move |cx| {
if let Poll::Ready(r) = a.as_mut().poll(cx) {
Poll::Ready(r)
} else if let Poll::Ready(r) = b.as_mut().poll(cx) {
Poll::Ready(r)
} else {
Poll::Pending
}
})
}
let a = async { 42 };
let b = future::pending();
let v = naive_select(a, b).await;
assert_eq!(v, 42);
let a = future::pending();
let b = async { 27 };
let v = naive_select(a, b).await;
assert_eq!(v, 27);
let a = async { 42 };
let b = async { 27 };
let v = naive_select(a, b).await;
assert_eq!(v, 42); // biased towards `a` in case of tie!
}
}
#[rustc_test_marker = "library/core/src/future/poll_fn.rs - future::poll_fn::poll_fn (line 32)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/future/poll_fn.rs - future::poll_fn::poll_fn (line 32)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/future/poll_fn.rs",
start_line: 32,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_376 {
fn main() {
async fn run() {
use core::future::{self, Future};
use core::pin::pin;
use core::task::Poll;
/// Resolves to the first future that completes. In the event of a tie, `a` wins.
fn naive_select<T>(
a: impl Future<Output = T>,
b: impl Future<Output = T>,
) -> impl Future<Output = T>
{
async {
let (mut a, mut b) = (pin!(a), pin!(b));
future::poll_fn(move |cx| {
if let Poll::Ready(r) = a.as_mut().poll(cx) {
Poll::Ready(r)
} else if let Poll::Ready(r) = b.as_mut().poll(cx) {
Poll::Ready(r)
} else {
Poll::Pending
}
}).await
}
}
let a = async { 42 };
let b = future::pending();
let v = naive_select(a, b).await;
assert_eq!(v, 42);
}
}
#[rustc_test_marker = "library/core/src/future/poll_fn.rs - future::poll_fn::poll_fn (line 76)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/future/poll_fn.rs - future::poll_fn::poll_fn (line 76)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/future/poll_fn.rs",
start_line: 76,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_377 {
fn main() {
use std::future;
async fn run() {
let a = future::ready(1);
assert_eq!(a.await, 1);
}
}
#[rustc_test_marker = "library/core/src/future/ready.rs - future::ready::ready (line 59)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/future/ready.rs - future::ready::ready (line 59)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/future/ready.rs",
start_line: 59,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_378 {
fn main() {
use std::hash::{DefaultHasher, Hash, Hasher};
#[derive(Hash)]
struct Person {
id: u32,
name: String,
phone: u64,
}
let person1 = Person {
id: 5,
name: "Janet".to_string(),
phone: 555_666_7777,
};
let person2 = Person {
id: 5,
name: "Bob".to_string(),
phone: 555_666_7777,
};
assert!(calculate_hash(&person1) != calculate_hash(&person2));
fn calculate_hash<T: Hash>(t: &T) -> u64 {
let mut s = DefaultHasher::new();
t.hash(&mut s);
s.finish()
}
}
#[rustc_test_marker = "library/core/src/hash/mod.rs - hash (line 14)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/hash/mod.rs - hash (line 14)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/hash/mod.rs",
start_line: 14,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_379 {
fn main() {
use std::hash::{DefaultHasher, Hash, Hasher};
struct Person {
id: u32,
#[allow(dead_code)]
name: String,
phone: u64,
}
impl Hash for Person {
fn hash<H: Hasher>(&self, state: &mut H) {
self.id.hash(state);
self.phone.hash(state);
}
}
let person1 = Person {
id: 5,
name: "Janet".to_string(),
phone: 555_666_7777,
};
let person2 = Person {
id: 5,
name: "Bob".to_string(),
phone: 555_666_7777,
};
assert_eq!(calculate_hash(&person1), calculate_hash(&person2));
fn calculate_hash<T: Hash>(t: &T) -> u64 {
let mut s = DefaultHasher::new();
t.hash(&mut s);
s.finish()
}
}
#[rustc_test_marker = "library/core/src/hash/mod.rs - hash (line 47)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/hash/mod.rs - hash (line 47)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/hash/mod.rs",
start_line: 47,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_380 {
fn main() {
use std::hash::{BuildHasher, Hasher, RandomState};
let s = RandomState::new();
let mut hasher_1 = s.build_hasher();
let mut hasher_2 = s.build_hasher();
hasher_1.write_u32(8128);
hasher_2.write_u32(8128);
assert_eq!(hasher_1.finish(), hasher_2.finish());
}
#[rustc_test_marker = "library/core/src/hash/mod.rs - hash::BuildHasher (line 623)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/hash/mod.rs - hash::BuildHasher (line 623)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/hash/mod.rs",
start_line: 623,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_381 {
fn main() {
use std::hash::{BuildHasher, RandomState};
let s = RandomState::new();
let new_s = s.build_hasher();
}
#[rustc_test_marker = "library/core/src/hash/mod.rs - hash::BuildHasher::build_hasher (line 651)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/hash/mod.rs - hash::BuildHasher::build_hasher (line 651)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/hash/mod.rs",
start_line: 651,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_382 {
fn main() {
use std::cmp::{max, min};
use std::hash::{BuildHasher, Hash, Hasher};
struct OrderAmbivalentPair<T: Ord>(T, T);
impl<T: Ord + Hash> Hash for OrderAmbivalentPair<T> {
fn hash<H: Hasher>(&self, hasher: &mut H) {
min(&self.0, &self.1).hash(hasher);
max(&self.0, &self.1).hash(hasher);
}
}
// Then later, in a `#[test]` for the type...
let bh = std::hash::RandomState::new();
assert_eq!(
bh.hash_one(OrderAmbivalentPair(1, 2)),
bh.hash_one(OrderAmbivalentPair(2, 1))
);
assert_eq!(
bh.hash_one(OrderAmbivalentPair(10, 2)),
bh.hash_one(&OrderAmbivalentPair(2, 10))
);
}
#[rustc_test_marker = "library/core/src/hash/mod.rs - hash::BuildHasher::hash_one (line 673)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/hash/mod.rs - hash::BuildHasher::hash_one (line 673)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/hash/mod.rs",
start_line: 673,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_383 {
fn main() {
use std::collections::HashMap;
use std::hash::{BuildHasherDefault, Hasher};
#[derive(Default)]
struct MyHasher;
impl Hasher for MyHasher {
fn write(&mut self, bytes: &[u8]) {
// Your hashing algorithm goes here!
unimplemented!()
}
fn finish(&self) -> u64 {
// Your hashing algorithm goes here!
unimplemented!()
}
}
type MyBuildHasher = BuildHasherDefault<MyHasher>;
let hash_map = HashMap::<u32, u32, MyBuildHasher>::default();
}
#[rustc_test_marker = "library/core/src/hash/mod.rs - hash::BuildHasherDefault (line 724)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/hash/mod.rs - hash::BuildHasherDefault (line 724)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/hash/mod.rs",
start_line: 724,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_384 {
fn main() {
#[derive(Hash)]
struct Rustacean {
name: String,
country: String,
}
}
#[rustc_test_marker = "library/core/src/hash/mod.rs - hash::Hash (line 111)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/hash/mod.rs - hash::Hash (line 111)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/hash/mod.rs",
start_line: 111,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_385 {
fn main() {
use std::hash::{Hash, Hasher};
struct Person {
id: u32,
name: String,
phone: u64,
}
impl Hash for Person {
fn hash<H: Hasher>(&self, state: &mut H) {
self.id.hash(state);
self.phone.hash(state);
}
}
}
#[rustc_test_marker = "library/core/src/hash/mod.rs - hash::Hash (line 122)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/hash/mod.rs - hash::Hash (line 122)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/hash/mod.rs",
start_line: 122,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_386 {
fn main() {
use std::hash::{DefaultHasher, Hash, Hasher};
let mut hasher = DefaultHasher::new();
7920.hash(&mut hasher);
println!("Hash is {:x}!", hasher.finish());
}
#[rustc_test_marker = "library/core/src/hash/mod.rs - hash::Hash::hash (line 194)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/hash/mod.rs - hash::Hash::hash (line 194)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/hash/mod.rs",
start_line: 194,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_387 {
fn main() {
use std::hash::{DefaultHasher, Hash, Hasher};
let mut hasher = DefaultHasher::new();
let numbers = [6, 28, 496, 8128];
Hash::hash_slice(&numbers, &mut hasher);
println!("Hash is {:x}!", hasher.finish());
}
#[rustc_test_marker = "library/core/src/hash/mod.rs - hash::Hash::hash_slice (line 223)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/hash/mod.rs - hash::Hash::hash_slice (line 223)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/hash/mod.rs",
start_line: 223,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_388 {
fn main() {
fn foo(hasher: &mut impl std::hash::Hasher) {
hasher.write(&[1, 2]);
hasher.write(&[3, 4, 5, 6]);
}
}
#[rustc_test_marker = "library/core/src/hash/mod.rs - hash::Hasher (line 277)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/hash/mod.rs - hash::Hasher (line 277)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/hash/mod.rs",
start_line: 277,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_389 {
fn main() {
fn foo(hasher: &mut impl std::hash::Hasher) {
hasher.write(&[1, 2, 3, 4]);
hasher.write(&[5, 6]);
}
}
#[rustc_test_marker = "library/core/src/hash/mod.rs - hash::Hasher (line 284)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/hash/mod.rs - hash::Hasher (line 284)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/hash/mod.rs",
start_line: 284,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_390 {
fn main() {
use std::hash::{DefaultHasher, Hasher};
let mut hasher = DefaultHasher::new();
hasher.write_u32(1989);
hasher.write_u8(11);
hasher.write_u8(9);
hasher.write(b"Huh?");
println!("Hash is {:x}!", hasher.finish());
}
#[rustc_test_marker = "library/core/src/hash/mod.rs - hash::Hasher (line 298)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/hash/mod.rs - hash::Hasher (line 298)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/hash/mod.rs",
start_line: 298,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_391 {
fn main() {
use std::hash::{DefaultHasher, Hasher};
let mut hasher = DefaultHasher::new();
hasher.write(b"Cool!");
println!("Hash is {:x}!", hasher.finish());
}
#[rustc_test_marker = "library/core/src/hash/mod.rs - hash::Hasher::finish (line 326)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/hash/mod.rs - hash::Hasher::finish (line 326)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/hash/mod.rs",
start_line: 326,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_392 {
fn main() {
use std::hash::{DefaultHasher, Hasher};
let mut hasher = DefaultHasher::new();
let data = [0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef];
hasher.write(&data);
println!("Hash is {:x}!", hasher.finish());
}
#[rustc_test_marker = "library/core/src/hash/mod.rs - hash::Hasher::write (line 343)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/hash/mod.rs - hash::Hasher::write (line 343)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/hash/mod.rs",
start_line: 343,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_393 {
fn main() {
fn contains(haystack: &[&str], needle: &str) -> bool {
haystack.iter().any(|x| x == &needle)
}
pub fn benchmark() {
let haystack = vec!["abc", "def", "ghi", "jkl", "mno"];
let needle = "ghi";
for _ in 0..10 {
contains(&haystack, needle);
}
}
}
#[rustc_test_marker = "library/core/src/hint.rs - hint::black_box (line 278)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/hint.rs - hint::black_box (line 278)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/hint.rs",
start_line: 278,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_394 {
fn main() {
use std::hint::black_box;
// Same `contains` function
fn contains(haystack: &[&str], needle: &str) -> bool {
haystack.iter().any(|x| x == &needle)
}
pub fn benchmark() {
let haystack = vec!["abc", "def", "ghi", "jkl", "mno"];
let needle = "ghi";
for _ in 0..10 {
// Adjust our benchmark loop contents
black_box(contains(black_box(&haystack), black_box(needle)));
}
}
}
#[rustc_test_marker = "library/core/src/hint.rs - hint::black_box (line 306)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/hint.rs - hint::black_box (line 306)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/hint.rs",
start_line: 306,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_395 {
fn main() {
struct Error;
fn f(arg: &str) -> Result<(), Error>
{ Ok(()) }
#[test]
fn t() {
// Assert that `f` returns error if passed an empty string.
// A value of type `Error` is unused here but that's not a problem.
f("").unwrap_err();
}
}
#[rustc_test_marker = "library/core/src/hint.rs - hint::must_use (line 396)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/hint.rs - hint::must_use (line 396)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/hint.rs",
start_line: 396,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_396 {
fn main() -> Result<(), impl core::fmt::Debug> {
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::{hint, thread};
// A shared atomic value that threads will use to coordinate
let live = Arc::new(AtomicBool::new(false));
// In a background thread we'll eventually set the value
let bg_work = {
let live = live.clone();
thread::spawn(move || {
// Do some work, then make the value live
do_some_work();
live.store(true, Ordering::Release);
})
};
// Back on our current thread, we wait for the value to be set
while !live.load(Ordering::Acquire) {
// The spin loop is a hint to the CPU that we're waiting, but probably
// not for very long
hint::spin_loop();
}
// The value is now set
fn do_some_work() {}
do_some_work();
bg_work.join()?;
Ok::<(), Box<dyn core::any::Any + Send + 'static>>(())
}
#[rustc_test_marker = "library/core/src/hint.rs - hint::spin_loop (line 182)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/hint.rs - hint::spin_loop (line 182)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/hint.rs",
start_line: 182,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_397 {
fn main() {
fn prepare_inputs(divisors: &mut Vec<u32>) {
// Note to future-self when making changes: The invariant established
// here is NOT checked in `do_computation()`; if this changes, you HAVE
// to change `do_computation()`.
divisors.retain(|divisor| *divisor != 0)
}
/// # Safety
/// All elements of `divisor` must be non-zero.
unsafe fn do_computation(i: u32, divisors: &[u32]) -> u32 {
divisors.iter().fold(i, |acc, divisor| {
// Convince the compiler that a division by zero can't happen here
// and a check is not needed below.
if *divisor == 0 {
// Safety: `divisor` can't be zero because of `prepare_inputs`,
// but the compiler does not know about this. We *promise*
// that we always call `prepare_inputs`.
std::hint::unreachable_unchecked()
}
// The compiler would normally introduce a check here that prevents
// a division by zero. However, if `divisor` was zero, the branch
// above would reach what we explicitly marked as unreachable.
// The compiler concludes that `divisor` can't be zero at this point
// and removes the - now proven useless - check.
acc / divisor
})
}
let mut divisors = vec![2, 0, 4];
prepare_inputs(&mut divisors);
let result = unsafe {
// Safety: prepare_inputs() guarantees that divisors is non-zero
do_computation(100, &divisors)
};
assert_eq!(result, 12);
}
#[rustc_test_marker = "library/core/src/hint.rs - hint::unreachable_unchecked (line 37)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/hint.rs - hint::unreachable_unchecked (line 37)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/hint.rs",
start_line: 37,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_398 {
fn main() {
fn div_1(a: u32, b: u32) -> u32 {
use std::hint::unreachable_unchecked;
// `b.saturating_add(1)` is always positive (not zero),
// hence `checked_div` will never return `None`.
// Therefore, the else branch is unreachable.
a.checked_div(b.saturating_add(1))
.unwrap_or_else(|| unsafe { unreachable_unchecked() })
}
assert_eq!(div_1(7, 0), 7);
assert_eq!(div_1(9, 1), 4);
assert_eq!(div_1(11, u32::MAX), 0);
}
#[rustc_test_marker = "library/core/src/hint.rs - hint::unreachable_unchecked (line 82)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/hint.rs - hint::unreachable_unchecked (line 82)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/hint.rs",
start_line: 82,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_399 {
#[rustc_test_marker = "library/core/src/internal_macros.rs - internal_macros::cfg_if (line 93)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/internal_macros.rs - internal_macros::cfg_if (line 93)"),
ignore: true,
ignore_message: None,
source_file: "library/core/src/internal_macros.rs",
start_line: 93,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_400 {
fn main() {
use std::ptr;
/// # Safety
///
/// * `ptr` must be correctly aligned for its type and non-zero.
/// * `ptr` must be valid for reads of `elts` contiguous elements of type `T`.
/// * Those elements must not be used after calling this function unless `T: Copy`.
#[allow(dead_code)]
unsafe fn from_buf_raw<T>(ptr: *const T, elts: usize) -> Vec<T> {
let mut dst = Vec::with_capacity(elts);
// SAFETY: Our precondition ensures the source is aligned and valid,
// and `Vec::with_capacity` ensures that we have usable space to write them.
ptr::copy(ptr, dst.as_mut_ptr(), elts);
// SAFETY: We created it with this much capacity earlier,
// and the previous `copy` has initialized these elements.
dst.set_len(elts);
dst
}
}
#[rustc_test_marker = "library/core/src/intrinsics.rs - intrinsics::copy (line 3007)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/intrinsics.rs - intrinsics::copy (line 3007)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/intrinsics.rs",
start_line: 3007,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_401 {
fn main() {
use std::ptr;
/// Moves all the elements of `src` into `dst`, leaving `src` empty.
fn append<T>(dst: &mut Vec<T>, src: &mut Vec<T>) {
let src_len = src.len();
let dst_len = dst.len();
// Ensure that `dst` has enough capacity to hold all of `src`.
dst.reserve(src_len);
unsafe {
// The call to add is always safe because `Vec` will never
// allocate more than `isize::MAX` bytes.
let dst_ptr = dst.as_mut_ptr().add(dst_len);
let src_ptr = src.as_ptr();
// Truncate `src` without dropping its contents. We do this first,
// to avoid problems in case something further down panics.
src.set_len(0);
// The two regions cannot overlap because mutable references do
// not alias, and two different vectors cannot own the same
// memory.
ptr::copy_nonoverlapping(src_ptr, dst_ptr, src_len);
// Notify `dst` that it now holds the contents of `src`.
dst.set_len(dst_len + src_len);
}
}
let mut a = vec!['r'];
let mut b = vec!['u', 's', 't'];
append(&mut a, &mut b);
assert_eq!(a, &['r', 'u', 's', 't']);
assert!(b.is_empty());
}
#[rustc_test_marker = "library/core/src/intrinsics.rs - intrinsics::copy_nonoverlapping (line 2886)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/intrinsics.rs - intrinsics::copy_nonoverlapping (line 2886)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/intrinsics.rs",
start_line: 2886,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_402 {
fn main() {
fn foo() -> i32 {
0
}
// Crucially, we `as`-cast to a raw pointer before `transmute`ing to a function pointer.
// This avoids an integer-to-pointer `transmute`, which can be problematic.
// Transmuting between raw pointers and function pointers (i.e., two pointer types) is fine.
let pointer = foo as *const ();
let function = unsafe {
std::mem::transmute::<*const (), fn() -> i32>(pointer)
};
assert_eq!(function(), 0);
}
#[rustc_test_marker = "library/core/src/intrinsics.rs - intrinsics::transmute (line 1219)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/intrinsics.rs - intrinsics::transmute (line 1219)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/intrinsics.rs",
start_line: 1219,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_403 {
fn main() {
struct R<'a>(&'a i32);
unsafe fn extend_lifetime<'b>(r: R<'b>) -> R<'static> {
std::mem::transmute::<R<'b>, R<'static>>(r)
}
unsafe fn shorten_invariant_lifetime<'b, 'c>(r: &'b mut R<'static>)
-> &'b mut R<'c> {
std::mem::transmute::<&'b mut R<'static>, &'b mut R<'c>>(r)
}
}
#[rustc_test_marker = "library/core/src/intrinsics.rs - intrinsics::transmute (line 1236)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/intrinsics.rs - intrinsics::transmute (line 1236)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/intrinsics.rs",
start_line: 1236,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_404 {
fn main() {
let raw_bytes = [0x78, 0x56, 0x34, 0x12];
let num = unsafe {
std::mem::transmute::<[u8; 4], u32>(raw_bytes)
};
// use `u32::from_ne_bytes` instead
let num = u32::from_ne_bytes(raw_bytes);
// or use `u32::from_le_bytes` or `u32::from_be_bytes` to specify the endianness
let num = u32::from_le_bytes(raw_bytes);
assert_eq!(num, 0x12345678);
let num = u32::from_be_bytes(raw_bytes);
assert_eq!(num, 0x78563412);
}
#[rustc_test_marker = "library/core/src/intrinsics.rs - intrinsics::transmute (line 1256)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/intrinsics.rs - intrinsics::transmute (line 1256)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/intrinsics.rs",
start_line: 1256,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_405 {
fn main() {
let ptr = &0;
let ptr_num_transmute = unsafe {
std::mem::transmute::<&i32, usize>(ptr)
};
// Use an `as` cast instead
let ptr_num_cast = ptr as *const i32 as usize;
}
#[rustc_test_marker = "library/core/src/intrinsics.rs - intrinsics::transmute (line 1274)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/intrinsics.rs - intrinsics::transmute (line 1274)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/intrinsics.rs",
start_line: 1274,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: true,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_406 {
fn main() {
let ptr: *mut i32 = &mut 0;
let ref_transmuted = unsafe {
std::mem::transmute::<*mut i32, &mut i32>(ptr)
};
// Use a reborrow instead
let ref_casted = unsafe { &mut *ptr };
}
#[rustc_test_marker = "library/core/src/intrinsics.rs - intrinsics::transmute (line 1296)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/intrinsics.rs - intrinsics::transmute (line 1296)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/intrinsics.rs",
start_line: 1296,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_407 {
fn main() {
let ptr = &mut 0;
let val_transmuted = unsafe {
std::mem::transmute::<&mut i32, &mut u32>(ptr)
};
// Now, put together `as` and reborrowing - note the chaining of `as`
// `as` is not transitive
let val_casts = unsafe { &mut *(ptr as *mut i32 as *mut u32) };
}
#[rustc_test_marker = "library/core/src/intrinsics.rs - intrinsics::transmute (line 1308)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/intrinsics.rs - intrinsics::transmute (line 1308)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/intrinsics.rs",
start_line: 1308,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_408 {
fn main() {
let slice = unsafe { std::mem::transmute::<&str, &[u8]>("Rust") };
assert_eq!(slice, &[82, 117, 115, 116]);
// You could use `str::as_bytes`
let slice = "Rust".as_bytes();
assert_eq!(slice, &[82, 117, 115, 116]);
// Or, just use a byte string, if you have control over the string
// literal
assert_eq!(b"Rust", &[82, 117, 115, 116]);
}
#[rustc_test_marker = "library/core/src/intrinsics.rs - intrinsics::transmute (line 1321)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/intrinsics.rs - intrinsics::transmute (line 1321)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/intrinsics.rs",
start_line: 1321,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_409 {
fn main() {
let store = [0, 1, 2, 3];
let v_orig = store.iter().collect::<Vec<&i32>>();
// clone the vector as we will reuse them later
let v_clone = v_orig.clone();
// Using transmute: this relies on the unspecified data layout of `Vec`, which is a
// bad idea and could cause Undefined Behavior.
// However, it is no-copy.
let v_transmuted = unsafe {
std::mem::transmute::<Vec<&i32>, Vec<Option<&i32>>>(v_clone)
};
let v_clone = v_orig.clone();
// This is the suggested, safe way.
// It may copy the entire vector into a new one though, but also may not.
let v_collected = v_clone.into_iter()
.map(Some)
.collect::<Vec<Option<&i32>>>();
let v_clone = v_orig.clone();
// This is the proper no-copy, unsafe way of "transmuting" a `Vec`, without relying on the
// data layout. Instead of literally calling `transmute`, we perform a pointer cast, but
// in terms of converting the original inner type (`&i32`) to the new one (`Option<&i32>`),
// this has all the same caveats. Besides the information provided above, also consult the
// [`from_raw_parts`] documentation.
let v_from_raw = unsafe {
// Ensure the original vector is not dropped.
let mut v_clone = std::mem::ManuallyDrop::new(v_clone);
Vec::from_raw_parts(v_clone.as_mut_ptr() as *mut Option<&i32>,
v_clone.len(),
v_clone.capacity())
};
}
#[rustc_test_marker = "library/core/src/intrinsics.rs - intrinsics::transmute (line 1343)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/intrinsics.rs - intrinsics::transmute (line 1343)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/intrinsics.rs",
start_line: 1343,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_410 {
fn main() {
use std::{slice, mem};
// There are multiple ways to do this, and there are multiple problems
// with the following (transmute) way.
fn split_at_mut_transmute<T>(slice: &mut [T], mid: usize)
-> (&mut [T], &mut [T]) {
let len = slice.len();
assert!(mid <= len);
unsafe {
let slice2 = mem::transmute::<&mut [T], &mut [T]>(slice);
// first: transmute is not type safe; all it checks is that T and
// U are of the same size. Second, right here, you have two
// mutable references pointing to the same memory.
(&mut slice[0..mid], &mut slice2[mid..len])
}
}
// This gets rid of the type safety problems; `&mut *` will *only* give
// you an `&mut T` from an `&mut T` or `*mut T`.
fn split_at_mut_casts<T>(slice: &mut [T], mid: usize)
-> (&mut [T], &mut [T]) {
let len = slice.len();
assert!(mid <= len);
unsafe {
let slice2 = &mut *(slice as *mut [T]);
// however, you still have two mutable references pointing to
// the same memory.
(&mut slice[0..mid], &mut slice2[mid..len])
}
}
// This is how the standard library does it. This is the best method, if
// you need to do something like this
fn split_at_stdlib<T>(slice: &mut [T], mid: usize)
-> (&mut [T], &mut [T]) {
let len = slice.len();
assert!(mid <= len);
unsafe {
let ptr = slice.as_mut_ptr();
// This now has three mutable references pointing at the same
// memory. `slice`, the rvalue ret.0, and the rvalue ret.1.
// `slice` is never used after `let ptr = ...`, and so one can
// treat it as "dead", and therefore, you only have two real
// mutable slices.
(slice::from_raw_parts_mut(ptr, mid),
slice::from_raw_parts_mut(ptr.add(mid), len - mid))
}
}
}
#[rustc_test_marker = "library/core/src/intrinsics.rs - intrinsics::transmute (line 1385)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/intrinsics.rs - intrinsics::transmute (line 1385)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/intrinsics.rs",
start_line: 1385,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_411 {
fn main() {
unsafe {
let mut value: u8 = 0;
let ptr: *mut bool = &mut value as *mut u8 as *mut bool;
let _bool = ptr.read(); // This is fine, `ptr` points to a valid `bool`.
ptr.write_bytes(42u8, 1); // This function itself does not cause UB...
let _bool = ptr.read(); // ...but it makes this operation UB! ⚠️
}
}
#[rustc_test_marker = "library/core/src/intrinsics.rs - intrinsics::write_bytes (line 3084)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/intrinsics.rs - intrinsics::write_bytes (line 3084)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/intrinsics.rs",
start_line: 3084,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: true,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_412 {
fn main() {
use std::ptr;
let mut vec = vec![0u32; 4];
unsafe {
let vec_ptr = vec.as_mut_ptr();
ptr::write_bytes(vec_ptr, 0xfe, 2);
}
assert_eq!(vec, [0xfefefefe, 0xfefefefe, 0, 0]);
}
#[rustc_test_marker = "library/core/src/intrinsics.rs - intrinsics::write_bytes (line 3100)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/intrinsics.rs - intrinsics::write_bytes (line 3100)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/intrinsics.rs",
start_line: 3100,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_413 {
fn main() {
use std::iter::Chain;
use std::slice::Iter;
let a1 = [1, 2, 3];
let a2 = [4, 5, 6];
let iter: Chain<Iter<'_, _>, Iter<'_, _>> = a1.iter().chain(a2.iter());
}
#[rustc_test_marker = "library/core/src/iter/adapters/chain.rs - iter::adapters::chain::Chain (line 12)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/adapters/chain.rs - iter::adapters::chain::Chain (line 12)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/adapters/chain.rs",
start_line: 12,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_414 {
fn main() {
use core::iter::Chain;
use core::slice;
use std::collections::{btree_set, BTreeSet};
use std::mem;
struct Foo<'a>(Chain<slice::Iter<'a, u8>, btree_set::Iter<'a, u8>>);
let set = BTreeSet::<u8>::new();
let slice: &[u8] = &[];
let mut foo = Foo(slice.iter().chain(set.iter()));
// take requires `Default`
let _: Chain<_, _> = mem::take(&mut foo.0);
}
#[rustc_test_marker = "library/core/src/iter/adapters/chain.rs - iter::adapters::chain::Chain<A,B>::default (line 313)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/adapters/chain.rs - iter::adapters::chain::Chain<A,B>::default (line 313)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/adapters/chain.rs",
start_line: 313,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_415 {
fn main() {
use core::slice;
use core::iter::Cloned;
let iter: Cloned<slice::Iter<'_, u8>> = Default::default();
assert_eq!(iter.len(), 0);
}
#[rustc_test_marker = "library/core/src/iter/adapters/cloned.rs - iter::adapters::cloned::Cloned<I>::default (line 161)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/adapters/cloned.rs - iter::adapters::cloned::Cloned<I>::default (line 161)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/adapters/cloned.rs",
start_line: 161,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_416 {
fn main() {
use core::slice;
use core::iter::Copied;
let iter: Copied<slice::Iter<'_, u8>> = Default::default();
assert_eq!(iter.len(), 0);
}
#[rustc_test_marker = "library/core/src/iter/adapters/copied.rs - iter::adapters::copied::Copied<I>::default (line 248)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/adapters/copied.rs - iter::adapters::copied::Copied<I>::default (line 248)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/adapters/copied.rs",
start_line: 248,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_417 {
fn main() {
use core::slice;
use std::iter::Enumerate;
let iter: Enumerate<slice::Iter<'_, u8>> = Default::default();
assert_eq!(iter.len(), 0);
}
#[rustc_test_marker = "library/core/src/iter/adapters/enumerate.rs - iter::adapters::enumerate::Enumerate<I>::default (line 276)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/adapters/enumerate.rs - iter::adapters::enumerate::Enumerate<I>::default (line 276)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/adapters/enumerate.rs",
start_line: 276,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_418 {
fn main() {
use core::slice;
use std::iter::Flatten;
let iter: Flatten<slice::Iter<'_, [u8; 4]>> = Default::default();
assert_eq!(iter.count(), 0);
}
#[rustc_test_marker = "library/core/src/iter/adapters/flatten.rs - iter::adapters::flatten::Flatten<I>::default (line 428)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/adapters/flatten.rs - iter::adapters::flatten::Flatten<I>::default (line 428)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/adapters/flatten.rs",
start_line: 428,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_419 {
fn main() {
use core::slice;
use std::iter::Fuse;
let iter: Fuse<slice::Iter<'_, u8>> = Default::default();
assert_eq!(iter.len(), 0);
}
#[rustc_test_marker = "library/core/src/iter/adapters/fuse.rs - iter::adapters::fuse::Fuse<I>::default (line 195)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/adapters/fuse.rs - iter::adapters::fuse::Fuse<I>::default (line 195)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/adapters/fuse.rs",
start_line: 195,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_420 {
fn main() {
let v: Vec<i32> = [1, 2, 3].into_iter().map(|x| x + 1).rev().collect();
assert_eq!(v, [4, 3, 2]);
}
#[rustc_test_marker = "library/core/src/iter/adapters/map.rs - iter::adapters::map::Map (line 22)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/adapters/map.rs - iter::adapters::map::Map (line 22)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/adapters/map.rs",
start_line: 22,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_421 {
fn main() {
let mut c = 0;
for pair in ['a', 'b', 'c'].into_iter()
.map(|letter| { c += 1; (letter, c) }) {
println!("{pair:?}");
}
}
#[rustc_test_marker = "library/core/src/iter/adapters/map.rs - iter::adapters::map::Map (line 33)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/adapters/map.rs - iter::adapters::map::Map (line 33)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/adapters/map.rs",
start_line: 33,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_422 {
fn main() {
let mut c = 0;
for pair in ['a', 'b', 'c'].into_iter()
.map(|letter| { c += 1; (letter, c) })
.rev() {
println!("{pair:?}");
}
}
#[rustc_test_marker = "library/core/src/iter/adapters/map.rs - iter::adapters::map::Map (line 50)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/adapters/map.rs - iter::adapters::map::Map (line 50)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/adapters/map.rs",
start_line: 50,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_423 {
fn main() {
let mut iter = (0..5).peekable();
// The first item of the iterator is 0; consume it.
assert_eq!(iter.next_if(|&x| x == 0), Some(0));
// The next item returned is now 1, so `consume` will return `false`.
assert_eq!(iter.next_if(|&x| x == 0), None);
// `next_if` saves the value of the next item if it was not equal to `expected`.
assert_eq!(iter.next(), Some(1));
}
#[rustc_test_marker = "library/core/src/iter/adapters/peekable.rs - iter::adapters::peekable::Peekable<I>::next_if (line 267)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/adapters/peekable.rs - iter::adapters::peekable::Peekable<I>::next_if (line 267)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/adapters/peekable.rs",
start_line: 267,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_424 {
fn main() {
let mut iter = (1..20).peekable();
// Consume all numbers less than 10
while iter.next_if(|&x| x < 10).is_some() {}
// The next value returned will be 10
assert_eq!(iter.next(), Some(10));
}
#[rustc_test_marker = "library/core/src/iter/adapters/peekable.rs - iter::adapters::peekable::Peekable<I>::next_if (line 278)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/adapters/peekable.rs - iter::adapters::peekable::Peekable<I>::next_if (line 278)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/adapters/peekable.rs",
start_line: 278,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_425 {
fn main() {
let mut iter = (0..5).peekable();
// The first item of the iterator is 0; consume it.
assert_eq!(iter.next_if_eq(&0), Some(0));
// The next item returned is now 1, so `consume` will return `false`.
assert_eq!(iter.next_if_eq(&0), None);
// `next_if_eq` saves the value of the next item if it was not equal to `expected`.
assert_eq!(iter.next(), Some(1));
}
#[rustc_test_marker = "library/core/src/iter/adapters/peekable.rs - iter::adapters::peekable::Peekable<I>::next_if_eq (line 302)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/adapters/peekable.rs - iter::adapters::peekable::Peekable<I>::next_if_eq (line 302)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/adapters/peekable.rs",
start_line: 302,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_426 {
fn main() {
let xs = [1, 2, 3];
let mut iter = xs.iter().peekable();
// peek() lets us see into the future
assert_eq!(iter.peek(), Some(&&1));
assert_eq!(iter.next(), Some(&1));
assert_eq!(iter.next(), Some(&2));
// The iterator does not advance even if we `peek` multiple times
assert_eq!(iter.peek(), Some(&&3));
assert_eq!(iter.peek(), Some(&&3));
assert_eq!(iter.next(), Some(&3));
// After the iterator is finished, so is `peek()`
assert_eq!(iter.peek(), None);
assert_eq!(iter.next(), None);
}
#[rustc_test_marker = "library/core/src/iter/adapters/peekable.rs - iter::adapters::peekable::Peekable<I>::peek (line 192)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/adapters/peekable.rs - iter::adapters::peekable::Peekable<I>::peek (line 192)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/adapters/peekable.rs",
start_line: 192,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_427 {
fn main() {
let mut iter = [1, 2, 3].iter().peekable();
// Like with `peek()`, we can see into the future without advancing the iterator.
assert_eq!(iter.peek_mut(), Some(&mut &1));
assert_eq!(iter.peek_mut(), Some(&mut &1));
assert_eq!(iter.next(), Some(&1));
// Peek into the iterator and set the value behind the mutable reference.
if let Some(p) = iter.peek_mut() {
assert_eq!(*p, &2);
*p = &5;
}
// The value we put in reappears as the iterator continues.
assert_eq!(iter.collect::<Vec<_>>(), vec![&5, &3]);
}
#[rustc_test_marker = "library/core/src/iter/adapters/peekable.rs - iter::adapters::peekable::Peekable<I>::peek_mut (line 236)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/adapters/peekable.rs - iter::adapters::peekable::Peekable<I>::peek_mut (line 236)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/adapters/peekable.rs",
start_line: 236,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_428 {
fn main() {
use core::slice;
use core::iter::Rev;
let iter: Rev<slice::Iter<'_, u8>> = Default::default();
assert_eq!(iter.len(), 0);
}
#[rustc_test_marker = "library/core/src/iter/adapters/rev.rs - iter::adapters::rev::Rev<I>::default (line 143)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/adapters/rev.rs - iter::adapters::rev::Rev<I>::default (line 143)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/adapters/rev.rs",
start_line: 143,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_429 {
fn main() {
use std::iter::zip;
let xs = [1, 2, 3];
let ys = [4, 5, 6];
let mut iter = zip(xs, ys);
assert_eq!(iter.next().unwrap(), (1, 4));
assert_eq!(iter.next().unwrap(), (2, 5));
assert_eq!(iter.next().unwrap(), (3, 6));
assert!(iter.next().is_none());
// Nested zips are also possible:
let zs = [7, 8, 9];
let mut iter = zip(zip(xs, ys), zs);
assert_eq!(iter.next().unwrap(), ((1, 4), 7));
assert_eq!(iter.next().unwrap(), ((2, 5), 8));
assert_eq!(iter.next().unwrap(), ((3, 6), 9));
assert!(iter.next().is_none());
}
#[rustc_test_marker = "library/core/src/iter/adapters/zip.rs - iter::adapters::zip::zip (line 43)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/adapters/zip.rs - iter::adapters::zip::zip (line 43)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/adapters/zip.rs",
start_line: 43,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_430 {
fn main() {
let values = vec![1, 2, 3, 4, 5];
for x in values {
println!("{x}");
}
}
#[rustc_test_marker = "library/core/src/iter/mod.rs - iter (line 143)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/mod.rs - iter (line 143)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/mod.rs",
start_line: 143,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_431 {
fn main() {
let values = vec![1, 2, 3, 4, 5];
for x in values {
println!("{x}");
}
}
#[rustc_test_marker = "library/core/src/iter/mod.rs - iter (line 163)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/mod.rs - iter (line 163)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/mod.rs",
start_line: 163,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_432 {
fn main() {
let values = vec![1, 2, 3, 4, 5];
{
let result = match IntoIterator::into_iter(values) {
mut iter => loop {
let next;
match iter.next() {
Some(val) => next = val,
None => break,
};
let x = next;
let () = { println!("{x}"); };
},
};
result
}
}
#[rustc_test_marker = "library/core/src/iter/mod.rs - iter (line 173)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/mod.rs - iter (line 173)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/mod.rs",
start_line: 173,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_433 {
#[rustc_test_marker = "library/core/src/iter/mod.rs - iter (line 198)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/mod.rs - iter (line 198)"),
ignore: true,
ignore_message: None,
source_file: "library/core/src/iter/mod.rs",
start_line: 198,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_434 {
fn main() {
let mut values = vec![41];
for x in values.iter_mut() {
*x += 1;
}
for x in values.iter() {
assert_eq!(*x, 42);
}
assert_eq!(values.len(), 1); // `values` is still owned by this function.
}
#[rustc_test_marker = "library/core/src/iter/mod.rs - iter (line 217)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/mod.rs - iter (line 217)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/mod.rs",
start_line: 217,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_435 {
fn main() {
let mut values = vec![41];
for x in &mut values { // same as `values.iter_mut()`
*x += 1;
}
for x in &values { // same as `values.iter()`
assert_eq!(*x, 42);
}
assert_eq!(values.len(), 1);
}
#[rustc_test_marker = "library/core/src/iter/mod.rs - iter (line 234)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/mod.rs - iter (line 234)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/mod.rs",
start_line: 234,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_436 {
fn main() {
#![allow(unused_must_use)]
#![allow(map_unit_fn)]
let v = vec![1, 2, 3, 4, 5];
v.iter().map(|x| println!("{x}"));
}
#[rustc_test_marker = "library/core/src/iter/mod.rs - iter (line 279)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/mod.rs - iter (line 279)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/mod.rs",
start_line: 279,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_437 {
fn main() {
let v = vec![1, 2, 3, 4, 5];
v.iter().for_each(|x| println!("{x}"));
// or
for x in &v {
println!("{x}");
}
}
#[rustc_test_marker = "library/core/src/iter/mod.rs - iter (line 297)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/mod.rs - iter (line 297)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/mod.rs",
start_line: 297,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_438 {
fn main() {
let numbers = 0..;
}
#[rustc_test_marker = "library/core/src/iter/mod.rs - iter (line 320)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/mod.rs - iter (line 320)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/mod.rs",
start_line: 320,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_439 {
fn main() {
let numbers = 0..;
let five_numbers = numbers.take(5);
for number in five_numbers {
println!("{number}");
}
}
#[rustc_test_marker = "library/core/src/iter/mod.rs - iter (line 327)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/mod.rs - iter (line 327)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/mod.rs",
start_line: 327,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_440 {
fn main() {
trait Iterator {
type Item;
fn next(&mut self) -> Option<Self::Item>;
}
}
#[rustc_test_marker = "library/core/src/iter/mod.rs - iter (line 34)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/mod.rs - iter (line 34)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/mod.rs",
start_line: 34,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_441 {
fn main() {
let ones = std::iter::repeat(1);
let least = ones.min().unwrap(); // Oh no! An infinite loop!
// `ones.min()` causes an infinite loop, so we won't reach this point!
println!("The smallest number one is {least}.");
}
#[rustc_test_marker = "library/core/src/iter/mod.rs - iter (line 344)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/mod.rs - iter (line 344)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/mod.rs",
start_line: 344,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: true,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_442 {
fn main() {
/// An iterator which counts from one to five
struct Counter {
count: usize,
}
// we want our count to start at one, so let's add a new() method to help.
// This isn't strictly necessary, but is convenient. Note that we start
// `count` at zero, we'll see why in `next()`'s implementation below.
impl Counter {
fn new() -> Counter {
Counter { count: 0 }
}
}
// Then, we implement `Iterator` for our `Counter`:
impl Iterator for Counter {
// we will be counting with usize
type Item = usize;
// next() is the only required method
fn next(&mut self) -> Option<Self::Item> {
// Increment our count. This is why we started at zero.
self.count += 1;
// Check to see if we've finished counting or not.
if self.count < 6 {
Some(self.count)
} else {
None
}
}
}
// And now we can use it!
let mut counter = Counter::new();
assert_eq!(counter.next(), Some(1));
assert_eq!(counter.next(), Some(2));
assert_eq!(counter.next(), Some(3));
assert_eq!(counter.next(), Some(4));
assert_eq!(counter.next(), Some(5));
assert_eq!(counter.next(), None);
}
#[rustc_test_marker = "library/core/src/iter/mod.rs - iter (line 80)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/mod.rs - iter (line 80)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/mod.rs",
start_line: 80,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_443 {
fn main() {
use std::iter;
// this could have been an iterator over i32, but alas, it's just not.
let mut nope = iter::empty::<i32>();
assert_eq!(None, nope.next());
}
#[rustc_test_marker = "library/core/src/iter/sources/empty.rs - iter::sources::empty::empty (line 11)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/sources/empty.rs - iter::sources::empty::empty (line 11)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/sources/empty.rs",
start_line: 11,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_444 {
fn main() {
let mut count = 0;
let counter = std::iter::from_fn(move || {
// Increment our count. This is why we started at zero.
count += 1;
// Check to see if we've finished counting or not.
if count < 6 {
Some(count)
} else {
None
}
});
assert_eq!(counter.collect::<Vec<_>>(), &[1, 2, 3, 4, 5]);
}
#[rustc_test_marker = "library/core/src/iter/sources/from_fn.rs - iter::sources::from_fn::from_fn (line 26)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/sources/from_fn.rs - iter::sources::from_fn::from_fn (line 26)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/sources/from_fn.rs",
start_line: 26,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_445 {
fn main() {
use std::iter;
// one is the loneliest number
let mut one = iter::once(1);
assert_eq!(Some(1), one.next());
// just one, that's all we get
assert_eq!(None, one.next());
}
#[rustc_test_marker = "library/core/src/iter/sources/once.rs - iter::sources::once::once (line 16)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/sources/once.rs - iter::sources::once::once (line 16)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/sources/once.rs",
start_line: 16,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_446 {
fn main() {
use std::iter;
use std::fs;
use std::path::PathBuf;
let dirs = fs::read_dir(".foo").unwrap();
// we need to convert from an iterator of DirEntry-s to an iterator of
// PathBufs, so we use map
let dirs = dirs.map(|file| file.unwrap().path());
// now, our iterator just for our config file
let config = iter::once(PathBuf::from(".foorc"));
// chain the two iterators together into one big iterator
let files = dirs.chain(config);
// this will give us all of the files in .foo as well as .foorc
for f in files {
println!("{f:?}");
}
}
#[rustc_test_marker = "library/core/src/iter/sources/once.rs - iter::sources::once::once (line 32)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/sources/once.rs - iter::sources::once::once (line 32)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/sources/once.rs",
start_line: 32,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: true,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_447 {
fn main() {
use std::iter;
// one is the loneliest number
let mut one = iter::once_with(|| 1);
assert_eq!(Some(1), one.next());
// just one, that's all we get
assert_eq!(None, one.next());
}
#[rustc_test_marker = "library/core/src/iter/sources/once_with.rs - iter::sources::once_with::once_with (line 21)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/sources/once_with.rs - iter::sources::once_with::once_with (line 21)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/sources/once_with.rs",
start_line: 21,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_448 {
fn main() {
use std::iter;
use std::fs;
use std::path::PathBuf;
let dirs = fs::read_dir(".foo").unwrap();
// we need to convert from an iterator of DirEntry-s to an iterator of
// PathBufs, so we use map
let dirs = dirs.map(|file| file.unwrap().path());
// now, our iterator just for our config file
let config = iter::once_with(|| PathBuf::from(".foorc"));
// chain the two iterators together into one big iterator
let files = dirs.chain(config);
// this will give us all of the files in .foo as well as .foorc
for f in files {
println!("{f:?}");
}
}
#[rustc_test_marker = "library/core/src/iter/sources/once_with.rs - iter::sources::once_with::once_with (line 37)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/sources/once_with.rs - iter::sources::once_with::once_with (line 37)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/sources/once_with.rs",
start_line: 37,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: true,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_449 {
fn main() {
use std::iter;
// the number four 4ever:
let mut fours = iter::repeat(4);
assert_eq!(Some(4), fours.next());
assert_eq!(Some(4), fours.next());
assert_eq!(Some(4), fours.next());
assert_eq!(Some(4), fours.next());
assert_eq!(Some(4), fours.next());
// yup, still four
assert_eq!(Some(4), fours.next());
}
#[rustc_test_marker = "library/core/src/iter/sources/repeat.rs - iter::sources::repeat::repeat (line 21)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/sources/repeat.rs - iter::sources::repeat::repeat (line 21)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/sources/repeat.rs",
start_line: 21,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_450 {
fn main() {
use std::iter;
// that last example was too many fours. Let's only have four fours.
let mut four_fours = iter::repeat(4).take(4);
assert_eq!(Some(4), four_fours.next());
assert_eq!(Some(4), four_fours.next());
assert_eq!(Some(4), four_fours.next());
assert_eq!(Some(4), four_fours.next());
// ... and now we're done
assert_eq!(None, four_fours.next());
}
#[rustc_test_marker = "library/core/src/iter/sources/repeat.rs - iter::sources::repeat::repeat (line 39)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/sources/repeat.rs - iter::sources::repeat::repeat (line 39)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/sources/repeat.rs",
start_line: 39,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_451 {
fn main() {
use std::iter;
// let's assume we have some value of a type that is not `Clone`
// or which we don't want to have in memory just yet because it is expensive:
#[derive(PartialEq, Debug)]
struct Expensive;
// a particular value forever:
let mut things = iter::repeat_with(|| Expensive);
assert_eq!(Some(Expensive), things.next());
assert_eq!(Some(Expensive), things.next());
assert_eq!(Some(Expensive), things.next());
assert_eq!(Some(Expensive), things.next());
assert_eq!(Some(Expensive), things.next());
}
#[rustc_test_marker = "library/core/src/iter/sources/repeat_with.rs - iter::sources::repeat_with::repeat_with (line 27)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/sources/repeat_with.rs - iter::sources::repeat_with::repeat_with (line 27)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/sources/repeat_with.rs",
start_line: 27,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_452 {
fn main() {
use std::iter;
// From the zeroth to the third power of two:
let mut curr = 1;
let mut pow2 = iter::repeat_with(|| { let tmp = curr; curr *= 2; tmp })
.take(4);
assert_eq!(Some(1), pow2.next());
assert_eq!(Some(2), pow2.next());
assert_eq!(Some(4), pow2.next());
assert_eq!(Some(8), pow2.next());
// ... and now we're done
assert_eq!(None, pow2.next());
}
#[rustc_test_marker = "library/core/src/iter/sources/repeat_with.rs - iter::sources::repeat_with::repeat_with (line 47)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/sources/repeat_with.rs - iter::sources::repeat_with::repeat_with (line 47)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/sources/repeat_with.rs",
start_line: 47,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_453 {
fn main() {
use std::iter::successors;
let powers_of_10 = successors(Some(1_u16), |n| n.checked_mul(10));
assert_eq!(powers_of_10.collect::<Vec<_>>(), &[1, 10, 100, 1_000, 10_000]);
}
#[rustc_test_marker = "library/core/src/iter/sources/successors.rs - iter::sources::successors::successors (line 8)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/sources/successors.rs - iter::sources::successors::successors (line 8)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/sources/successors.rs",
start_line: 8,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_454 {
fn main() {
let nums = vec!["5", "10", "1", "2"];
let total: Option<usize> = nums.iter().map(|w| w.parse::<usize>().ok()).product();
assert_eq!(total, Some(100));
let nums = vec!["5", "10", "one", "2"];
let total: Option<usize> = nums.iter().map(|w| w.parse::<usize>().ok()).product();
assert_eq!(total, None);
}
#[rustc_test_marker = "library/core/src/iter/traits/accum.rs - iter::traits::accum::Option<T>::product (line 257)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/accum.rs - iter::traits::accum::Option<T>::product (line 257)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/accum.rs",
start_line: 257,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_455 {
fn main() {
let words = vec!["have", "a", "great", "day"];
let total: Option<usize> = words.iter().map(|w| w.find('a')).sum();
assert_eq!(total, Some(5));
let words = vec!["have", "a", "good", "day"];
let total: Option<usize> = words.iter().map(|w| w.find('a')).sum();
assert_eq!(total, None);
}
#[rustc_test_marker = "library/core/src/iter/traits/accum.rs - iter::traits::accum::Option<T>::sum (line 227)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/accum.rs - iter::traits::accum::Option<T>::sum (line 227)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/accum.rs",
start_line: 227,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_456 {
fn main() {
let nums = vec!["5", "10", "1", "2"];
let total: Result<usize, _> = nums.iter().map(|w| w.parse::<usize>()).product();
assert_eq!(total, Ok(100));
let nums = vec!["5", "10", "one", "2"];
let total: Result<usize, _> = nums.iter().map(|w| w.parse::<usize>()).product();
assert!(total.is_err());
}
#[rustc_test_marker = "library/core/src/iter/traits/accum.rs - iter::traits::accum::Result<T,E>::product (line 197)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/accum.rs - iter::traits::accum::Result<T,E>::product (line 197)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/accum.rs",
start_line: 197,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_457 {
fn main() {
let f = |&x: &i32| if x < 0 { Err("Negative element found") } else { Ok(x) };
let v = vec![1, 2];
let res: Result<i32, _> = v.iter().map(f).sum();
assert_eq!(res, Ok(3));
let v = vec![1, -2];
let res: Result<i32, _> = v.iter().map(f).sum();
assert_eq!(res, Err("Negative element found"));
}
#[rustc_test_marker = "library/core/src/iter/traits/accum.rs - iter::traits::accum::Result<T,E>::sum (line 166)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/accum.rs - iter::traits::accum::Result<T,E>::sum (line 166)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/accum.rs",
start_line: 166,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_458 {
fn main() -> Result<(), core::num::ParseIntError> {
let string = "1,2,123,4";
let (numbers, lengths): (Vec<_>, Vec<_>) = string
.split(',')
.map(|s| s.parse().map(|n: u32| (n, s.len())))
.collect::<Result<_, _>>()?;
assert_eq!(numbers, [1, 2, 123, 4]);
assert_eq!(lengths, [1, 1, 3, 1]);
Ok(()) }
#[rustc_test_marker = "library/core/src/iter/traits/collect.rs - iter::traits::collect::(A,B) (line 159)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/collect.rs - iter::traits::collect::(A,B) (line 159)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/collect.rs",
start_line: 159,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_459 {
fn main() {
let mut tuple = (vec![0], vec![1]);
tuple.extend([(2, 3), (4, 5), (6, 7)]);
assert_eq!(tuple.0, [0, 2, 4, 6]);
assert_eq!(tuple.1, [1, 3, 5, 7]);
// also allows for arbitrarily nested tuples as elements
let mut nested_tuple = (vec![1], (vec![2], vec![3]));
nested_tuple.extend([(4, (5, 6)), (7, (8, 9))]);
let (a, (b, c)) = nested_tuple;
assert_eq!(a, [1, 4, 7]);
assert_eq!(b, [2, 5, 8]);
assert_eq!(c, [3, 6, 9]);
}
#[rustc_test_marker = "library/core/src/iter/traits/collect.rs - iter::traits::collect::(ExtendA,ExtendB)::extend (line 485)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/collect.rs - iter::traits::collect::(ExtendA,ExtendB)::extend (line 485)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/collect.rs",
start_line: 485,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_460 {
fn main() {
let mut message = String::from("The first three letters are: ");
message.extend(&['a', 'b', 'c']);
assert_eq!("abc", &message[29..32]);
}
#[rustc_test_marker = "library/core/src/iter/traits/collect.rs - iter::traits::collect::Extend (line 373)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/collect.rs - iter::traits::collect::Extend (line 373)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/collect.rs",
start_line: 373,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_461 {
fn main() {
#[derive(Debug)]
struct MyCollection(Vec<i32>);
// Let's give it some methods so we can create one and add things
// to it.
impl MyCollection {
fn new() -> MyCollection {
MyCollection(Vec::new())
}
fn add(&mut self, elem: i32) {
self.0.push(elem);
}
}
// since MyCollection has a list of i32s, we implement Extend for i32
impl Extend<i32> for MyCollection {
// This is a bit simpler with the concrete type signature: we can call
// extend on anything which can be turned into an Iterator which gives
// us i32s. Because we need i32s to put into MyCollection.
fn extend<T: IntoIterator<Item=i32>>(&mut self, iter: T) {
// The implementation is very straightforward: loop through the
// iterator, and add() each element to ourselves.
for elem in iter {
self.add(elem);
}
}
}
let mut c = MyCollection::new();
c.add(5);
c.add(6);
c.add(7);
// let's extend our collection with three more numbers
c.extend(vec![1, 2, 3]);
// we've added these elements onto the end
assert_eq!("MyCollection([5, 6, 7, 1, 2, 3])", format!("{c:?}"));
}
#[rustc_test_marker = "library/core/src/iter/traits/collect.rs - iter::traits::collect::Extend (line 384)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/collect.rs - iter::traits::collect::Extend (line 384)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/collect.rs",
start_line: 384,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_462 {
fn main() {
let mut message = String::from("abc");
message.extend(['d', 'e', 'f'].iter());
assert_eq!("abcdef", &message);
}
#[rustc_test_marker = "library/core/src/iter/traits/collect.rs - iter::traits::collect::Extend::extend (line 440)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/collect.rs - iter::traits::collect::Extend::extend (line 440)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/collect.rs",
start_line: 440,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_463 {
fn main() {
let five_fives = std::iter::repeat(5).take(5);
let v = Vec::from_iter(five_fives);
assert_eq!(v, vec![5, 5, 5, 5, 5]);
}
#[rustc_test_marker = "library/core/src/iter/traits/collect.rs - iter::traits::collect::FromIterator (line 19)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/collect.rs - iter::traits::collect::FromIterator (line 19)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/collect.rs",
start_line: 19,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_464 {
fn main() {
let five_fives = std::iter::repeat(5).take(5);
let v: Vec<i32> = five_fives.collect();
assert_eq!(v, vec![5, 5, 5, 5, 5]);
}
#[rustc_test_marker = "library/core/src/iter/traits/collect.rs - iter::traits::collect::FromIterator (line 29)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/collect.rs - iter::traits::collect::FromIterator (line 29)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/collect.rs",
start_line: 29,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_465 {
fn main() {
use std::collections::VecDeque;
let first = (0..10).collect::<VecDeque<i32>>();
let second = VecDeque::from_iter(0..10);
assert_eq!(first, second);
}
#[rustc_test_marker = "library/core/src/iter/traits/collect.rs - iter::traits::collect::FromIterator (line 40)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/collect.rs - iter::traits::collect::FromIterator (line 40)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/collect.rs",
start_line: 40,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_466 {
fn main() {
#[derive(Debug)]
struct MyCollection(Vec<i32>);
// Let's give it some methods so we can create one and add things
// to it.
impl MyCollection {
fn new() -> MyCollection {
MyCollection(Vec::new())
}
fn add(&mut self, elem: i32) {
self.0.push(elem);
}
}
// and we'll implement FromIterator
impl FromIterator<i32> for MyCollection {
fn from_iter<I: IntoIterator<Item=i32>>(iter: I) -> Self {
let mut c = MyCollection::new();
for i in iter {
c.add(i);
}
c
}
}
// Now we can make a new iterator...
let iter = (0..5).into_iter();
// ... and make a MyCollection out of it
let c = MyCollection::from_iter(iter);
assert_eq!(c.0, vec![0, 1, 2, 3, 4]);
// collect works too!
let iter = (0..5).into_iter();
let c: MyCollection = iter.collect();
assert_eq!(c.0, vec![0, 1, 2, 3, 4]);
}
#[rustc_test_marker = "library/core/src/iter/traits/collect.rs - iter::traits::collect::FromIterator (line 50)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/collect.rs - iter::traits::collect::FromIterator (line 50)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/collect.rs",
start_line: 50,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_467 {
fn main() {
let five_fives = std::iter::repeat(5).take(5);
let v = Vec::from_iter(five_fives);
assert_eq!(v, vec![5, 5, 5, 5, 5]);
}
#[rustc_test_marker = "library/core/src/iter/traits/collect.rs - iter::traits::collect::FromIterator::from_iter (line 141)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/collect.rs - iter::traits::collect::FromIterator::from_iter (line 141)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/collect.rs",
start_line: 141,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_468 {
fn main() {
let v = [1, 2, 3];
let mut iter = v.into_iter();
assert_eq!(Some(1), iter.next());
assert_eq!(Some(2), iter.next());
assert_eq!(Some(3), iter.next());
assert_eq!(None, iter.next());
}
#[rustc_test_marker = "library/core/src/iter/traits/collect.rs - iter::traits::collect::IntoIterator (line 201)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/collect.rs - iter::traits::collect::IntoIterator (line 201)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/collect.rs",
start_line: 201,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_469 {
fn main() {
#[derive(Debug)]
struct MyCollection(Vec<i32>);
// Let's give it some methods so we can create one and add things
// to it.
impl MyCollection {
fn new() -> MyCollection {
MyCollection(Vec::new())
}
fn add(&mut self, elem: i32) {
self.0.push(elem);
}
}
// and we'll implement IntoIterator
impl IntoIterator for MyCollection {
type Item = i32;
type IntoIter = std::vec::IntoIter<Self::Item>;
fn into_iter(self) -> Self::IntoIter {
self.0.into_iter()
}
}
// Now we can make a new collection...
let mut c = MyCollection::new();
// ... add some stuff to it ...
c.add(0);
c.add(1);
c.add(2);
// ... and then turn it into an Iterator:
for (i, n) in c.into_iter().enumerate() {
assert_eq!(i as i32, n);
}
}
#[rustc_test_marker = "library/core/src/iter/traits/collect.rs - iter::traits::collect::IntoIterator (line 212)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/collect.rs - iter::traits::collect::IntoIterator (line 212)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/collect.rs",
start_line: 212,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_470 {
fn main() {
fn collect_as_strings<T>(collection: T) -> Vec<String>
where
T: IntoIterator,
T::Item: std::fmt::Debug,
{
collection
.into_iter()
.map(|item| format!("{item:?}"))
.collect()
}
}
#[rustc_test_marker = "library/core/src/iter/traits/collect.rs - iter::traits::collect::IntoIterator (line 258)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/collect.rs - iter::traits::collect::IntoIterator (line 258)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/collect.rs",
start_line: 258,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_471 {
fn main() {
let v = [1, 2, 3];
let mut iter = v.into_iter();
assert_eq!(Some(1), iter.next());
assert_eq!(Some(2), iter.next());
assert_eq!(Some(3), iter.next());
assert_eq!(None, iter.next());
}
#[rustc_test_marker = "library/core/src/iter/traits/collect.rs - iter::traits::collect::IntoIterator::into_iter (line 334)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/collect.rs - iter::traits::collect::IntoIterator::into_iter (line 334)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/collect.rs",
start_line: 334,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_472 {
fn main() {
let numbers = vec![1, 2, 3, 4, 5, 6];
let mut iter = numbers.iter();
assert_eq!(Some(&1), iter.next());
assert_eq!(Some(&6), iter.next_back());
assert_eq!(Some(&5), iter.next_back());
assert_eq!(Some(&2), iter.next());
assert_eq!(Some(&3), iter.next());
assert_eq!(Some(&4), iter.next());
assert_eq!(None, iter.next());
assert_eq!(None, iter.next_back());
}
#[rustc_test_marker = "library/core/src/iter/traits/double_ended.rs - iter::traits::double_ended::DoubleEndedIterator (line 25)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/double_ended.rs - iter::traits::double_ended::DoubleEndedIterator (line 25)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/double_ended.rs",
start_line: 25,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_473 {
fn main() {
let numbers = vec![1, 2, 3, 4, 5, 6];
let mut iter = numbers.iter();
assert_eq!(Some(&1), iter.next());
assert_eq!(Some(&6), iter.next_back());
assert_eq!(Some(&5), iter.next_back());
assert_eq!(Some(&2), iter.next());
assert_eq!(Some(&3), iter.next());
assert_eq!(Some(&4), iter.next());
assert_eq!(None, iter.next());
assert_eq!(None, iter.next_back());
}
#[rustc_test_marker = "library/core/src/iter/traits/double_ended.rs - iter::traits::double_ended::DoubleEndedIterator::next_back (line 54)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/double_ended.rs - iter::traits::double_ended::DoubleEndedIterator::next_back (line 54)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/double_ended.rs",
start_line: 54,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_474 {
fn main() {
let vec = vec![(1, 'a'), (1, 'b'), (1, 'c'), (2, 'a'), (2, 'b')];
let uniq_by_fst_comp = || {
let mut seen = std::collections::HashSet::new();
vec.iter().copied().filter(move |x| seen.insert(x.0))
};
assert_eq!(uniq_by_fst_comp().last(), Some((2, 'a')));
assert_eq!(uniq_by_fst_comp().next_back(), Some((2, 'b')));
assert_eq!(
uniq_by_fst_comp().fold(vec![], |mut v, x| {v.push(x); v}),
vec![(1, 'a'), (2, 'a')]
);
assert_eq!(
uniq_by_fst_comp().rfold(vec![], |mut v, x| {v.push(x); v}),
vec![(2, 'b'), (1, 'c')]
);
}
#[rustc_test_marker = "library/core/src/iter/traits/double_ended.rs - iter::traits::double_ended::DoubleEndedIterator::next_back (line 74)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/double_ended.rs - iter::traits::double_ended::DoubleEndedIterator::next_back (line 74)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/double_ended.rs",
start_line: 74,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_475 {
fn main() {
let a = [1, 2, 3];
assert_eq!(a.iter().nth_back(2), Some(&1));
}
#[rustc_test_marker = "library/core/src/iter/traits/double_ended.rs - iter::traits::double_ended::DoubleEndedIterator::nth_back (line 167)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/double_ended.rs - iter::traits::double_ended::DoubleEndedIterator::nth_back (line 167)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/double_ended.rs",
start_line: 167,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_476 {
fn main() {
let a = [1, 2, 3];
let mut iter = a.iter();
assert_eq!(iter.nth_back(1), Some(&2));
assert_eq!(iter.nth_back(1), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/double_ended.rs - iter::traits::double_ended::DoubleEndedIterator::nth_back (line 174)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/double_ended.rs - iter::traits::double_ended::DoubleEndedIterator::nth_back (line 174)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/double_ended.rs",
start_line: 174,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_477 {
fn main() {
let a = [1, 2, 3];
assert_eq!(a.iter().nth_back(10), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/double_ended.rs - iter::traits::double_ended::DoubleEndedIterator::nth_back (line 185)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/double_ended.rs - iter::traits::double_ended::DoubleEndedIterator::nth_back (line 185)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/double_ended.rs",
start_line: 185,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_478 {
fn main() {
let a = [1, 2, 3];
assert_eq!(a.iter().rfind(|&&x| x == 2), Some(&2));
assert_eq!(a.iter().rfind(|&&x| x == 5), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/double_ended.rs - iter::traits::double_ended::DoubleEndedIterator::rfind (line 334)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/double_ended.rs - iter::traits::double_ended::DoubleEndedIterator::rfind (line 334)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/double_ended.rs",
start_line: 334,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_479 {
fn main() {
let a = [1, 2, 3];
let mut iter = a.iter();
assert_eq!(iter.rfind(|&&x| x == 2), Some(&2));
// we can still use `iter`, as there are more elements.
assert_eq!(iter.next_back(), Some(&1));
}
#[rustc_test_marker = "library/core/src/iter/traits/double_ended.rs - iter::traits::double_ended::DoubleEndedIterator::rfind (line 344)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/double_ended.rs - iter::traits::double_ended::DoubleEndedIterator::rfind (line 344)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/double_ended.rs",
start_line: 344,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_480 {
fn main() {
let a = [1, 2, 3];
// the sum of all of the elements of a
let sum = a.iter()
.rfold(0, |acc, &x| acc + x);
assert_eq!(sum, 6);
}
#[rustc_test_marker = "library/core/src/iter/traits/double_ended.rs - iter::traits::double_ended::DoubleEndedIterator::rfold (line 273)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/double_ended.rs - iter::traits::double_ended::DoubleEndedIterator::rfold (line 273)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/double_ended.rs",
start_line: 273,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_481 {
fn main() {
let numbers = [1, 2, 3, 4, 5];
let zero = "0".to_string();
let result = numbers.iter().rfold(zero, |acc, &x| {
format!("({x} + {acc})")
});
assert_eq!(result, "(1 + (2 + (3 + (4 + (5 + 0)))))");
}
#[rustc_test_marker = "library/core/src/iter/traits/double_ended.rs - iter::traits::double_ended::DoubleEndedIterator::rfold (line 287)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/double_ended.rs - iter::traits::double_ended::DoubleEndedIterator::rfold (line 287)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/double_ended.rs",
start_line: 287,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_482 {
fn main() {
let a = ["1", "2", "3"];
let sum = a.iter()
.map(|&s| s.parse::<i32>())
.try_rfold(0, |acc, x| x.and_then(|y| Ok(acc + y)));
assert_eq!(sum, Ok(6));
}
#[rustc_test_marker = "library/core/src/iter/traits/double_ended.rs - iter::traits::double_ended::DoubleEndedIterator::try_rfold (line 205)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/double_ended.rs - iter::traits::double_ended::DoubleEndedIterator::try_rfold (line 205)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/double_ended.rs",
start_line: 205,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_483 {
fn main() {
let a = ["1", "rust", "3"];
let mut it = a.iter();
let sum = it
.by_ref()
.map(|&s| s.parse::<i32>())
.try_rfold(0, |acc, x| x.and_then(|y| Ok(acc + y)));
assert!(sum.is_err());
// Because it short-circuited, the remaining elements are still
// available through the iterator.
assert_eq!(it.next_back(), Some(&"1"));
}
#[rustc_test_marker = "library/core/src/iter/traits/double_ended.rs - iter::traits::double_ended::DoubleEndedIterator::try_rfold (line 215)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/double_ended.rs - iter::traits::double_ended::DoubleEndedIterator::try_rfold (line 215)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/double_ended.rs",
start_line: 215,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_484 {
fn main() {
let five = 0..5;
assert_eq!(5, five.len());
}
#[rustc_test_marker = "library/core/src/iter/traits/exact_size.rs - iter::traits::exact_size::ExactSizeIterator (line 38)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/exact_size.rs - iter::traits::exact_size::ExactSizeIterator (line 38)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/exact_size.rs",
start_line: 38,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_485 {
fn main() {
struct Counter {
count: usize,
}
impl Counter {
fn new() -> Counter {
Counter { count: 0 }
}
}
impl Iterator for Counter {
type Item = usize;
fn next(&mut self) -> Option<Self::Item> {
self.count += 1;
if self.count < 6 {
Some(self.count)
} else {
None
}
}
}
impl ExactSizeIterator for Counter {
// We can easily calculate the remaining number of iterations.
fn len(&self) -> usize {
5 - self.count
}
}
// And now we can use it!
let mut counter = Counter::new();
assert_eq!(5, counter.len());
let _ = counter.next();
assert_eq!(4, counter.len());
}
#[rustc_test_marker = "library/core/src/iter/traits/exact_size.rs - iter::traits::exact_size::ExactSizeIterator (line 50)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/exact_size.rs - iter::traits::exact_size::ExactSizeIterator (line 50)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/exact_size.rs",
start_line: 50,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_486 {
fn main() {
let mut range = 0..5;
assert_eq!(5, range.len());
let _ = range.next();
assert_eq!(4, range.len());
}
#[rustc_test_marker = "library/core/src/iter/traits/exact_size.rs - iter::traits::exact_size::ExactSizeIterator::len (line 106)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/exact_size.rs - iter::traits::exact_size::ExactSizeIterator::len (line 106)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/exact_size.rs",
start_line: 106,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_487 {
fn main() {
let a = [1, 2, 3];
assert!(a.iter().all(|&x| x > 0));
assert!(!a.iter().all(|&x| x > 2));
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::all (line 2727)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::all (line 2727)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 2727,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_488 {
fn main() {
let a = [1, 2, 3];
let mut iter = a.iter();
assert!(!iter.all(|&x| x != 2));
// we can still use `iter`, as there are more elements.
assert_eq!(iter.next(), Some(&3));
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::all (line 2737)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::all (line 2737)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 2737,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_489 {
fn main() {
let a = [1, 2, 3];
assert!(a.iter().any(|&x| x > 0));
assert!(!a.iter().any(|&x| x > 5));
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::any (line 2781)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::any (line 2781)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 2781,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_490 {
fn main() {
let a = [1, 2, 3];
let mut iter = a.iter();
assert!(iter.any(|&x| x != 2));
// we can still use `iter`, as there are more elements.
assert_eq!(iter.next(), Some(&2));
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::any (line 2791)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::any (line 2791)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 2791,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_491 {
fn main() {
let mut words = ["hello", "world", "of", "Rust"].into_iter();
// Take the first two words.
let hello_world: Vec<_> = words.by_ref().take(2).collect();
assert_eq!(hello_world, vec!["hello", "world"]);
// Collect the rest of the words.
// We can only do this because we used `by_ref` earlier.
let of_rust: Vec<_> = words.collect();
assert_eq!(of_rust, vec!["of", "Rust"]);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::by_ref (line 1867)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::by_ref (line 1867)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 1867,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_492 {
fn main() {
let a1 = [1, 2, 3];
let a2 = [4, 5, 6];
let mut iter = a1.iter().chain(a2.iter());
assert_eq!(iter.next(), Some(&1));
assert_eq!(iter.next(), Some(&2));
assert_eq!(iter.next(), Some(&3));
assert_eq!(iter.next(), Some(&4));
assert_eq!(iter.next(), Some(&5));
assert_eq!(iter.next(), Some(&6));
assert_eq!(iter.next(), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::chain (line 431)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::chain (line 431)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 431,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_493 {
fn main() {
let s1 = &[1, 2, 3];
let s2 = &[4, 5, 6];
let mut iter = s1.iter().chain(s2);
assert_eq!(iter.next(), Some(&1));
assert_eq!(iter.next(), Some(&2));
assert_eq!(iter.next(), Some(&3));
assert_eq!(iter.next(), Some(&4));
assert_eq!(iter.next(), Some(&5));
assert_eq!(iter.next(), Some(&6));
assert_eq!(iter.next(), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::chain (line 451)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::chain (line 451)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 451,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_494 {
fn main() {
#[cfg(windows)]
fn os_str_to_utf16(s: &std::ffi::OsStr) -> Vec<u16> {
use std::os::windows::ffi::OsStrExt;
s.encode_wide().chain(std::iter::once(0)).collect()
}
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::chain (line 468)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::chain (line 468)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 468,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_495 {
fn main() {
let a = [1, 2, 3];
let v_cloned: Vec<_> = a.iter().cloned().collect();
// cloned is the same as .map(|&x| x), for integers
let v_map: Vec<_> = a.iter().map(|&x| x).collect();
assert_eq!(v_cloned, vec![1, 2, 3]);
assert_eq!(v_map, vec![1, 2, 3]);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::cloned (line 3442)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::cloned (line 3442)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 3442,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_496 {
fn main() {
let a = [vec![0_u8, 1, 2], vec![3, 4], vec![23]];
// don't do this:
let slower: Vec<_> = a.iter().cloned().filter(|s| s.len() == 1).collect();
assert_eq!(&[vec![23]], &slower[..]);
// instead call `cloned` late
let faster: Vec<_> = a.iter().filter(|s| s.len() == 1).cloned().collect();
assert_eq!(&[vec![23]], &faster[..]);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::cloned (line 3456)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::cloned (line 3456)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 3456,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_497 {
fn main() {
use std::cmp::Ordering;
assert_eq!([1].iter().cmp([1].iter()), Ordering::Equal);
assert_eq!([1].iter().cmp([1, 2].iter()), Ordering::Less);
assert_eq!([1, 2].iter().cmp([1].iter()), Ordering::Greater);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::cmp (line 3622)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::cmp (line 3622)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 3622,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_498 {
fn main() {
let a = [1, 2, 3];
let doubled: Vec<i32> = a.iter()
.map(|&x| x * 2)
.collect();
assert_eq!(vec![2, 4, 6], doubled);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::collect (line 1913)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::collect (line 1913)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 1913,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_499 {
fn main() {
use std::collections::VecDeque;
let a = [1, 2, 3];
let doubled: VecDeque<i32> = a.iter().map(|&x| x * 2).collect();
assert_eq!(2, doubled[0]);
assert_eq!(4, doubled[1]);
assert_eq!(6, doubled[2]);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::collect (line 1928)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::collect (line 1928)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 1928,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_500 {
fn main() {
let a = [1, 2, 3];
let doubled = a.iter().map(|x| x * 2).collect::<Vec<i32>>();
assert_eq!(vec![2, 4, 6], doubled);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::collect (line 1942)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::collect (line 1942)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 1942,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_501 {
fn main() {
let a = [1, 2, 3];
let doubled = a.iter().map(|x| x * 2).collect::<Vec<_>>();
assert_eq!(vec![2, 4, 6], doubled);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::collect (line 1953)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::collect (line 1953)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 1953,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_502 {
fn main() {
let chars = ['g', 'd', 'k', 'k', 'n'];
let hello: String = chars.iter()
.map(|&x| x as u8)
.map(|x| (x + 1) as char)
.collect();
assert_eq!("hello", hello);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::collect (line 1963)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::collect (line 1963)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 1963,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_503 {
fn main() {
let results = [Ok(1), Err("nope"), Ok(3), Err("bad")];
let result: Result<Vec<_>, &str> = results.iter().cloned().collect();
// gives us the first error
assert_eq!(Err("nope"), result);
let results = [Ok(1), Ok(3)];
let result: Result<Vec<_>, &str> = results.iter().cloned().collect();
// gives us the list of answers
assert_eq!(Ok(vec![1, 3]), result);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::collect (line 1977)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::collect (line 1977)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 1977,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_504 {
fn main() {
let a = [1, 2, 3];
let v_copied: Vec<_> = a.iter().copied().collect();
// copied is the same as .map(|&x| x)
let v_map: Vec<_> = a.iter().map(|&x| x).collect();
assert_eq!(v_copied, vec![1, 2, 3]);
assert_eq!(v_map, vec![1, 2, 3]);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::copied (line 3406)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::copied (line 3406)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 3406,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_505 {
fn main() {
let a = [1, 2, 3];
assert_eq!(a.iter().count(), 3);
let a = [1, 2, 3, 4, 5];
assert_eq!(a.iter().count(), 5);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::count (line 219)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::count (line 219)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 219,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_506 {
fn main() {
let a = [1, 2, 3];
let mut it = a.iter().cycle();
assert_eq!(it.next(), Some(&1));
assert_eq!(it.next(), Some(&2));
assert_eq!(it.next(), Some(&3));
assert_eq!(it.next(), Some(&1));
assert_eq!(it.next(), Some(&2));
assert_eq!(it.next(), Some(&3));
assert_eq!(it.next(), Some(&1));
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::cycle (line 3484)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::cycle (line 3484)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 3484,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_507 {
fn main() {
let a = ['a', 'b', 'c'];
let mut iter = a.iter().enumerate();
assert_eq!(iter.next(), Some((0, &'a')));
assert_eq!(iter.next(), Some((1, &'b')));
assert_eq!(iter.next(), Some((2, &'c')));
assert_eq!(iter.next(), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::enumerate (line 964)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::enumerate (line 964)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 964,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_508 {
fn main() {
assert_eq!([1].iter().eq([1].iter()), true);
assert_eq!([1].iter().eq([1, 2].iter()), false);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::eq (line 3781)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::eq (line 3781)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 3781,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_509 {
fn main() {
let a = [0i32, 1, 2];
let mut iter = a.iter().filter(|x| x.is_positive());
assert_eq!(iter.next(), Some(&1));
assert_eq!(iter.next(), Some(&2));
assert_eq!(iter.next(), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::filter (line 832)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::filter (line 832)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 832,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_510 {
fn main() {
let a = [0, 1, 2];
let mut iter = a.iter().filter(|x| **x > 1); // need two *s!
assert_eq!(iter.next(), Some(&2));
assert_eq!(iter.next(), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::filter (line 846)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::filter (line 846)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 846,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_511 {
fn main() {
let a = [0, 1, 2];
let mut iter = a.iter().filter(|&x| *x > 1); // both & and *
assert_eq!(iter.next(), Some(&2));
assert_eq!(iter.next(), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::filter (line 858)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::filter (line 858)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 858,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_512 {
fn main() {
let a = [0, 1, 2];
let mut iter = a.iter().filter(|&&x| x > 1); // two &s
assert_eq!(iter.next(), Some(&2));
assert_eq!(iter.next(), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::filter (line 869)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::filter (line 869)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 869,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_513 {
fn main() {
let a = ["1", "two", "NaN", "four", "5"];
let mut iter = a.iter().filter_map(|s| s.parse().ok());
assert_eq!(iter.next(), Some(1));
assert_eq!(iter.next(), Some(5));
assert_eq!(iter.next(), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::filter_map (line 908)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::filter_map (line 908)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 908,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_514 {
fn main() {
let a = ["1", "two", "NaN", "four", "5"];
let mut iter = a.iter().map(|s| s.parse()).filter(|s| s.is_ok()).map(|s| s.unwrap());
assert_eq!(iter.next(), Some(1));
assert_eq!(iter.next(), Some(5));
assert_eq!(iter.next(), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::filter_map (line 920)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::filter_map (line 920)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 920,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_515 {
fn main() {
let a = [1, 2, 3];
assert_eq!(a.iter().find(|&&x| x == 2), Some(&2));
assert_eq!(a.iter().find(|&&x| x == 5), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::find (line 2843)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::find (line 2843)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 2843,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_516 {
fn main() {
let a = [1, 2, 3];
let mut iter = a.iter();
assert_eq!(iter.find(|&&x| x == 2), Some(&2));
// we can still use `iter`, as there are more elements.
assert_eq!(iter.next(), Some(&3));
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::find (line 2853)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::find (line 2853)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 2853,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_517 {
fn main() {
let a = ["lol", "NaN", "2", "5"];
let first_number = a.iter().find_map(|s| s.parse().ok());
assert_eq!(first_number, Some(2));
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::find_map (line 2890)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::find_map (line 2890)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 2890,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_518 {
fn main() {
let words = ["alpha", "beta", "gamma"];
// chars() returns an iterator
let merged: String = words.iter()
.flat_map(|s| s.chars())
.collect();
assert_eq!(merged, "alphabetagamma");
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::flat_map (line 1446)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::flat_map (line 1446)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 1446,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_519 {
fn main() {
let data = vec![vec![1, 2, 3, 4], vec![5, 6]];
let flattened = data.into_iter().flatten().collect::<Vec<u8>>();
assert_eq!(flattened, &[1, 2, 3, 4, 5, 6]);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::flatten (line 1477)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::flatten (line 1477)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 1477,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_520 {
fn main() {
let words = ["alpha", "beta", "gamma"];
// chars() returns an iterator
let merged: String = words.iter()
.map(|s| s.chars())
.flatten()
.collect();
assert_eq!(merged, "alphabetagamma");
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::flatten (line 1485)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::flatten (line 1485)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 1485,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_521 {
fn main() {
let words = ["alpha", "beta", "gamma"];
// chars() returns an iterator
let merged: String = words.iter()
.flat_map(|s| s.chars())
.collect();
assert_eq!(merged, "alphabetagamma");
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::flatten (line 1499)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::flatten (line 1499)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 1499,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_522 {
fn main() {
let options = vec![Some(123), Some(321), None, Some(231)];
let flattened_options: Vec<_> = options.into_iter().flatten().collect();
assert_eq!(flattened_options, vec![123, 321, 231]);
let results = vec![Ok(123), Ok(321), Err(456), Ok(231)];
let flattened_results: Vec<_> = results.into_iter().flatten().collect();
assert_eq!(flattened_results, vec![123, 321, 231]);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::flatten (line 1511)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::flatten (line 1511)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 1511,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_523 {
fn main() {
let d3 = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]];
let d2 = d3.iter().flatten().collect::<Vec<_>>();
assert_eq!(d2, [&[1, 2], &[3, 4], &[5, 6], &[7, 8]]);
let d1 = d3.iter().flatten().flatten().collect::<Vec<_>>();
assert_eq!(d1, [&1, &2, &3, &4, &5, &6, &7, &8]);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::flatten (line 1523)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::flatten (line 1523)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 1523,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_524 {
fn main() {
let a = [1, 2, 3];
// the sum of all of the elements of the array
let sum = a.iter().fold(0, |acc, x| acc + x);
assert_eq!(sum, 6);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::fold (line 2519)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::fold (line 2519)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 2519,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_525 {
fn main() {
let numbers = [1, 2, 3, 4, 5];
let zero = "0".to_string();
let result = numbers.iter().fold(zero, |acc, &x| {
format!("({acc} + {x})")
});
assert_eq!(result, "(((((0 + 1) + 2) + 3) + 4) + 5)");
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::fold (line 2543)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::fold (line 2543)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 2543,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_526 {
fn main() {
let numbers = [1, 2, 3, 4, 5];
let mut result = 0;
// for loop:
for i in &numbers {
result = result + i;
}
// fold:
let result2 = numbers.iter().fold(0, |acc, &x| acc + x);
// they're the same
assert_eq!(result, result2);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::fold (line 2560)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::fold (line 2560)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 2560,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_527 {
fn main() {
use std::sync::mpsc::channel;
let (tx, rx) = channel();
(0..5).map(|x| x * 2 + 1)
.for_each(move |x| tx.send(x).unwrap());
let v: Vec<_> = rx.iter().collect();
assert_eq!(v, vec![1, 3, 5, 7, 9]);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::for_each (line 785)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::for_each (line 785)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 785,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_528 {
fn main() {
(0..5).flat_map(|x| x * 100 .. x * 110)
.enumerate()
.filter(|&(i, x)| (i + x) % 3 == 0)
.for_each(|(i, x)| println!("{i}:{x}"));
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::for_each (line 799)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::for_each (line 799)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 799,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_529 {
fn main() {
struct Alternate {
state: i32,
}
impl Iterator for Alternate {
type Item = i32;
fn next(&mut self) -> Option<i32> {
let val = self.state;
self.state = self.state + 1;
// if it's even, Some(i32), else None
if val % 2 == 0 {
Some(val)
} else {
None
}
}
}
let mut iter = Alternate { state: 0 };
// we can see our iterator going back and forth
assert_eq!(iter.next(), Some(0));
assert_eq!(iter.next(), None);
assert_eq!(iter.next(), Some(2));
assert_eq!(iter.next(), None);
// however, once we fuse it...
let mut iter = iter.fuse();
assert_eq!(iter.next(), Some(4));
assert_eq!(iter.next(), None);
// it will always return `None` after the first time.
assert_eq!(iter.next(), None);
assert_eq!(iter.next(), None);
assert_eq!(iter.next(), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::fuse (line 1723)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::fuse (line 1723)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 1723,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_530 {
fn main() {
assert_eq!([1].iter().ge([1].iter()), true);
assert_eq!([1].iter().ge([1, 2].iter()), false);
assert_eq!([1, 2].iter().ge([1].iter()), true);
assert_eq!([1, 2].iter().ge([1, 2].iter()), true);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::ge (line 3924)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::ge (line 3924)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 3924,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_531 {
fn main() {
assert_eq!([1].iter().gt([1].iter()), false);
assert_eq!([1].iter().gt([1, 2].iter()), false);
assert_eq!([1, 2].iter().gt([1].iter()), true);
assert_eq!([1, 2].iter().gt([1, 2].iter()), false);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::gt (line 3902)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::gt (line 3902)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 3902,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_532 {
fn main() {
let a = [1, 4, 2, 3];
// this iterator sequence is complex.
let sum = a.iter()
.cloned()
.filter(|x| x % 2 == 0)
.fold(0, |sum, i| sum + i);
println!("{sum}");
// let's add some inspect() calls to investigate what's happening
let sum = a.iter()
.cloned()
.inspect(|x| println!("about to filter: {x}"))
.filter(|x| x % 2 == 0)
.inspect(|x| println!("made it through filter: {x}"))
.fold(0, |sum, i| sum + i);
println!("{sum}");
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::inspect (line 1789)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::inspect (line 1789)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 1789,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_533 {
fn main() {
let lines = ["1", "2", "a"];
let sum: i32 = lines
.iter()
.map(|line| line.parse::<i32>())
.inspect(|num| {
if let Err(ref e) = *num {
println!("Parsing error: {e}");
}
})
.filter_map(Result::ok)
.sum();
println!("Sum: {sum}");
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::inspect (line 1826)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::inspect (line 1826)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 1826,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_534 {
fn main() {
let a = [1, 2, 3];
assert_eq!(a.iter().last(), Some(&3));
let a = [1, 2, 3, 4, 5];
assert_eq!(a.iter().last(), Some(&5));
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::last (line 248)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::last (line 248)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 248,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_535 {
fn main() {
assert_eq!([1].iter().le([1].iter()), true);
assert_eq!([1].iter().le([1, 2].iter()), true);
assert_eq!([1, 2].iter().le([1].iter()), false);
assert_eq!([1, 2].iter().le([1, 2].iter()), true);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::le (line 3880)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::le (line 3880)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 3880,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_536 {
fn main() {
assert_eq!([1].iter().lt([1].iter()), false);
assert_eq!([1].iter().lt([1, 2].iter()), true);
assert_eq!([1, 2].iter().lt([1].iter()), false);
assert_eq!([1, 2].iter().lt([1, 2].iter()), false);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::lt (line 3858)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::lt (line 3858)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 3858,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_537 {
fn main() {
let a = [1, 2, 3];
let mut iter = a.iter().map(|x| 2 * x);
assert_eq!(iter.next(), Some(2));
assert_eq!(iter.next(), Some(4));
assert_eq!(iter.next(), Some(6));
assert_eq!(iter.next(), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::map (line 733)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::map (line 733)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 733,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_538 {
fn main() {
#![allow(unused_must_use)]
(0..5).map(|x| println!("{x}"));
// it won't even execute, as it is lazy. Rust will warn you about this.
// Instead, use for:
for x in 0..5 {
println!("{x}");
}
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::map (line 746)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::map (line 746)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 746,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_539 {
fn main() {
let a = [-1i32, 4, 0, 1];
let mut iter = a.iter().map_while(|x| 16i32.checked_div(*x));
assert_eq!(iter.next(), Some(-16));
assert_eq!(iter.next(), Some(4));
assert_eq!(iter.next(), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::map_while (line 1216)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::map_while (line 1216)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 1216,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_540 {
fn main() {
let a = [-1i32, 4, 0, 1];
let mut iter = a.iter()
.map(|x| 16i32.checked_div(*x))
.take_while(|x| x.is_some())
.map(|x| x.unwrap());
assert_eq!(iter.next(), Some(-16));
assert_eq!(iter.next(), Some(4));
assert_eq!(iter.next(), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::map_while (line 1231)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::map_while (line 1231)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 1231,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_541 {
fn main() {
let a = [0, 1, 2, -3, 4, 5, -6];
let iter = a.iter().map_while(|x| u32::try_from(*x).ok());
let vec = iter.collect::<Vec<_>>();
// We have more elements which could fit in u32 (4, 5), but `map_while` returned `None` for `-3`
// (as the `predicate` returned `None`) and `collect` stops at the first `None` encountered.
assert_eq!(vec, vec![0, 1, 2]);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::map_while (line 1246)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::map_while (line 1246)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 1246,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_542 {
fn main() {
let a = [1, 2, -3, 4];
let mut iter = a.iter();
let result: Vec<u32> = iter.by_ref()
.map_while(|n| u32::try_from(*n).ok())
.collect();
assert_eq!(result, &[1, 2]);
let result: Vec<i32> = iter.cloned().collect();
assert_eq!(result, &[4]);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::map_while (line 1261)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::map_while (line 1261)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 1261,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_543 {
fn main() {
assert_eq!(
[2.4, f32::NAN, 1.3]
.into_iter()
.reduce(f32::max)
.unwrap(),
2.4
);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::max (line 3135)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::max (line 3135)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 3135,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_544 {
fn main() {
let a = [1, 2, 3];
let b: Vec<u32> = Vec::new();
assert_eq!(a.iter().max(), Some(&3));
assert_eq!(b.iter().max(), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::max (line 3147)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::max (line 3147)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 3147,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_545 {
fn main() {
let a = [-3_i32, 0, 1, 5, -10];
assert_eq!(*a.iter().max_by(|x, y| x.cmp(y)).unwrap(), 5);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::max_by (line 3244)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::max_by (line 3244)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 3244,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_546 {
fn main() {
let a = [-3_i32, 0, 1, 5, -10];
assert_eq!(*a.iter().max_by_key(|x| x.abs()).unwrap(), -10);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::max_by_key (line 3210)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::max_by_key (line 3210)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 3210,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_547 {
fn main() {
assert_eq!(
[2.4, f32::NAN, 1.3]
.into_iter()
.reduce(f32::min)
.unwrap(),
1.3
);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::min (line 3172)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::min (line 3172)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 3172,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_548 {
fn main() {
let a = [1, 2, 3];
let b: Vec<u32> = Vec::new();
assert_eq!(a.iter().min(), Some(&1));
assert_eq!(b.iter().min(), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::min (line 3184)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::min (line 3184)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 3184,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_549 {
fn main() {
let a = [-3_i32, 0, 1, 5, -10];
assert_eq!(*a.iter().min_by(|x, y| x.cmp(y)).unwrap(), -10);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::min_by (line 3306)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::min_by (line 3306)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 3306,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_550 {
fn main() {
let a = [-3_i32, 0, 1, 5, -10];
assert_eq!(*a.iter().min_by_key(|x| x.abs()).unwrap(), 0);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::min_by_key (line 3272)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::min_by_key (line 3272)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 3272,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_551 {
fn main() {
assert_eq!([1].iter().ne([1].iter()), false);
assert_eq!([1].iter().ne([1, 2].iter()), true);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::ne (line 3838)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::ne (line 3838)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 3838,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_552 {
fn main() {
let a = [1, 2, 3];
let mut iter = a.iter();
// A call to next() returns the next value...
assert_eq!(Some(&1), iter.next());
assert_eq!(Some(&2), iter.next());
assert_eq!(Some(&3), iter.next());
// ... and then None once it's over.
assert_eq!(None, iter.next());
// More calls may or may not return `None`. Here, they always will.
assert_eq!(None, iter.next());
assert_eq!(None, iter.next());
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::next (line 61)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::next (line 61)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 61,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_553 {
fn main() {
let a = [1, 2, 3];
assert_eq!(a.iter().nth(1), Some(&2));
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::nth (line 333)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::nth (line 333)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 333,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_554 {
fn main() {
let a = [1, 2, 3];
let mut iter = a.iter();
assert_eq!(iter.nth(1), Some(&2));
assert_eq!(iter.nth(1), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::nth (line 340)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::nth (line 340)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 340,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_555 {
fn main() {
let a = [1, 2, 3];
assert_eq!(a.iter().nth(10), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::nth (line 351)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::nth (line 351)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 351,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_556 {
fn main() {
use std::cmp::Ordering;
assert_eq!([1.].iter().partial_cmp([1.].iter()), Some(Ordering::Equal));
assert_eq!([1.].iter().partial_cmp([1., 2.].iter()), Some(Ordering::Less));
assert_eq!([1., 2.].iter().partial_cmp([1.].iter()), Some(Ordering::Greater));
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::partial_cmp (line 3689)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::partial_cmp (line 3689)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 3689,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_557 {
fn main() {
assert_eq!([f64::NAN].iter().partial_cmp([1.].iter()), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::partial_cmp (line 3700)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::partial_cmp (line 3700)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 3700,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_558 {
fn main() {
use std::cmp::Ordering;
assert_eq!([1.0, f64::NAN].iter().partial_cmp([2.0, f64::NAN].iter()), Some(Ordering::Less));
assert_eq!([2.0, f64::NAN].iter().partial_cmp([1.0, f64::NAN].iter()), Some(Ordering::Greater));
assert_eq!([f64::NAN, 1.0].iter().partial_cmp([f64::NAN, 2.0].iter()), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::partial_cmp (line 3706)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::partial_cmp (line 3706)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 3706,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_559 {
fn main() {
let a = [1, 2, 3];
let (even, odd): (Vec<_>, Vec<_>) = a
.into_iter()
.partition(|n| n % 2 == 0);
assert_eq!(even, vec![2]);
assert_eq!(odd, vec![1, 3]);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::partition (line 2175)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::partition (line 2175)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 2175,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_560 {
fn main() {
let xs = [1, 2, 3];
let mut iter = xs.iter().peekable();
// peek() lets us see into the future
assert_eq!(iter.peek(), Some(&&1));
assert_eq!(iter.next(), Some(&1));
assert_eq!(iter.next(), Some(&2));
// we can peek() multiple times, the iterator won't advance
assert_eq!(iter.peek(), Some(&&3));
assert_eq!(iter.peek(), Some(&&3));
assert_eq!(iter.next(), Some(&3));
// after the iterator is finished, so is peek()
assert_eq!(iter.peek(), None);
assert_eq!(iter.next(), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::peekable (line 1000)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::peekable (line 1000)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 1000,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_561 {
fn main() {
let xs = [1, 2, 3];
let mut iter = xs.iter().peekable();
// `peek_mut()` lets us see into the future
assert_eq!(iter.peek_mut(), Some(&mut &1));
assert_eq!(iter.peek_mut(), Some(&mut &1));
assert_eq!(iter.next(), Some(&1));
if let Some(mut p) = iter.peek_mut() {
assert_eq!(*p, &2);
// put a value into the iterator
*p = &1000;
}
// The value reappears as the iterator continues
assert_eq!(iter.collect::<Vec<_>>(), vec![&1000, &3]);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::peekable (line 1025)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::peekable (line 1025)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 1025,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_562 {
fn main() {
let a = [1, 2, 3];
assert_eq!(a.iter().position(|&x| x == 2), Some(1));
assert_eq!(a.iter().position(|&x| x == 5), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::position (line 3015)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::position (line 3015)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 3015,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_563 {
fn main() {
let a = [1, 2, 3, 4];
let mut iter = a.iter();
assert_eq!(iter.position(|&x| x >= 2), Some(1));
// we can still use `iter`, as there are more elements.
assert_eq!(iter.next(), Some(&3));
// The returned index depends on iterator state
assert_eq!(iter.position(|&x| x == 4), Some(0));
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::position (line 3025)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::position (line 3025)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 3025,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_564 {
fn main() {
fn factorial(n: u32) -> u32 {
(1..=n).product()
}
assert_eq!(factorial(0), 1);
assert_eq!(factorial(1), 1);
assert_eq!(factorial(5), 120);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::product (line 3599)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::product (line 3599)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 3599,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_565 {
fn main() {
let reduced: i32 = (1..10).reduce(|acc, e| acc + e).unwrap();
assert_eq!(reduced, 45);
// Which is equivalent to doing it with `fold`:
let folded: i32 = (1..10).fold(0, |acc, e| acc + e);
assert_eq!(reduced, folded);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::reduce (line 2609)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::reduce (line 2609)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 2609,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_566 {
fn main() {
let a = [1, 2, 3];
let mut iter = a.iter().rev();
assert_eq!(iter.next(), Some(&3));
assert_eq!(iter.next(), Some(&2));
assert_eq!(iter.next(), Some(&1));
assert_eq!(iter.next(), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::rev (line 3336)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::rev (line 3336)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 3336,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_567 {
fn main() {
let a = [1, 2, 3];
assert_eq!(a.iter().rposition(|&x| x == 3), Some(2));
assert_eq!(a.iter().rposition(|&x| x == 5), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::rposition (line 3084)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::rposition (line 3084)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 3084,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_568 {
fn main() {
let a = [-1, 2, 3, 4];
let mut iter = a.iter();
assert_eq!(iter.rposition(|&x| x >= 2), Some(3));
// we can still use `iter`, as there are more elements.
assert_eq!(iter.next(), Some(&-1));
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::rposition (line 3094)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::rposition (line 3094)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 3094,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_569 {
fn main() {
let a = [1, 2, 3, 4];
let mut iter = a.iter().scan(1, |state, &x| {
// each iteration, we'll multiply the state by the element ...
*state = *state * x;
// ... and terminate if the state exceeds 6
if *state > 6 {
return None;
}
// ... else yield the negation of the state
Some(-*state)
});
assert_eq!(iter.next(), Some(-1));
assert_eq!(iter.next(), Some(-2));
assert_eq!(iter.next(), Some(-6));
assert_eq!(iter.next(), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::scan (line 1396)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::scan (line 1396)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 1396,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_570 {
fn main() {
let a = [1, 2, 3];
let mut iter = a.iter();
assert_eq!((3, Some(3)), iter.size_hint());
let _ = iter.next();
assert_eq!((2, Some(2)), iter.size_hint());
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::size_hint (line 155)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::size_hint (line 155)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 155,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_571 {
fn main() {
let iter = (0..10).filter(|x| x % 2 == 0);
// We might iterate from zero to ten times. Knowing that it's five
// exactly wouldn't be possible without executing filter().
assert_eq!((0, Some(10)), iter.size_hint());
// Let's add five more numbers with chain()
let iter = (0..10).filter(|x| x % 2 == 0).chain(15..20);
// now both bounds are increased by five
assert_eq!((5, Some(15)), iter.size_hint());
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::size_hint (line 166)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::size_hint (line 166)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 166,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_572 {
fn main() {
let iter = 0..;
assert_eq!((usize::MAX, None), iter.size_hint());
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::size_hint (line 183)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::size_hint (line 183)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 183,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_573 {
fn main() {
let a = [1, 2, 3];
let mut iter = a.iter().skip(2);
assert_eq!(iter.next(), Some(&3));
assert_eq!(iter.next(), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::skip (line 1306)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::skip (line 1306)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 1306,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_574 {
fn main() {
let a = [-1i32, 0, 1];
let mut iter = a.iter().skip_while(|x| x.is_negative());
assert_eq!(iter.next(), Some(&0));
assert_eq!(iter.next(), Some(&1));
assert_eq!(iter.next(), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::skip_while (line 1072)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::skip_while (line 1072)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 1072,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_575 {
fn main() {
let a = [-1, 0, 1];
let mut iter = a.iter().skip_while(|x| **x < 0); // need two *s!
assert_eq!(iter.next(), Some(&0));
assert_eq!(iter.next(), Some(&1));
assert_eq!(iter.next(), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::skip_while (line 1086)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::skip_while (line 1086)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 1086,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_576 {
fn main() {
let a = [-1, 0, 1, -2];
let mut iter = a.iter().skip_while(|x| **x < 0);
assert_eq!(iter.next(), Some(&0));
assert_eq!(iter.next(), Some(&1));
// while this would have been false, since we already got a false,
// skip_while() isn't used any more
assert_eq!(iter.next(), Some(&-2));
assert_eq!(iter.next(), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::skip_while (line 1098)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::skip_while (line 1098)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 1098,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_577 {
fn main() {
fn advance_n_and_return_first<I>(iter: &mut I, n: usize) -> Option<I::Item>
where
I: Iterator,
{
let next = iter.next();
if n > 1 {
iter.nth(n - 2);
}
next
}
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::step_by (line 378)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::step_by (line 378)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 378,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_578 {
fn main() {
let a = [0, 1, 2, 3, 4, 5];
let mut iter = a.iter().step_by(2);
assert_eq!(iter.next(), Some(&0));
assert_eq!(iter.next(), Some(&2));
assert_eq!(iter.next(), Some(&4));
assert_eq!(iter.next(), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::step_by (line 397)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::step_by (line 397)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 397,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_579 {
fn main() {
let a = [1, 2, 3];
let sum: i32 = a.iter().sum();
assert_eq!(sum, 6);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::sum (line 3568)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::sum (line 3568)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 3568,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_580 {
fn main() {
let a = [1, 2, 3];
let mut iter = a.iter().take(2);
assert_eq!(iter.next(), Some(&1));
assert_eq!(iter.next(), Some(&2));
assert_eq!(iter.next(), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::take (line 1337)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::take (line 1337)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 1337,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_581 {
fn main() {
let mut iter = (0..).take(3);
assert_eq!(iter.next(), Some(0));
assert_eq!(iter.next(), Some(1));
assert_eq!(iter.next(), Some(2));
assert_eq!(iter.next(), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::take (line 1349)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::take (line 1349)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 1349,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_582 {
fn main() {
let v = [1, 2];
let mut iter = v.into_iter().take(5);
assert_eq!(iter.next(), Some(1));
assert_eq!(iter.next(), Some(2));
assert_eq!(iter.next(), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::take (line 1361)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::take (line 1361)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 1361,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_583 {
fn main() {
let a = [-1i32, 0, 1];
let mut iter = a.iter().take_while(|x| x.is_negative());
assert_eq!(iter.next(), Some(&-1));
assert_eq!(iter.next(), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::take_while (line 1137)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::take_while (line 1137)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 1137,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_584 {
fn main() {
let a = [-1, 0, 1];
let mut iter = a.iter().take_while(|x| **x < 0); // need two *s!
assert_eq!(iter.next(), Some(&-1));
assert_eq!(iter.next(), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::take_while (line 1150)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::take_while (line 1150)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 1150,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_585 {
fn main() {
let a = [-1, 0, 1, -2];
let mut iter = a.iter().take_while(|x| **x < 0);
assert_eq!(iter.next(), Some(&-1));
// We have more elements that are less than zero, but since we already
// got a false, take_while() isn't used any more
assert_eq!(iter.next(), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::take_while (line 1161)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::take_while (line 1161)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 1161,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_586 {
fn main() {
let a = [1, 2, 3, 4];
let mut iter = a.iter();
let result: Vec<i32> = iter.by_ref()
.take_while(|n| **n != 3)
.cloned()
.collect();
assert_eq!(result, &[1, 2]);
let result: Vec<i32> = iter.cloned().collect();
assert_eq!(result, &[4]);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::take_while (line 1177)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::take_while (line 1177)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 1177,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_587 {
fn main() {
let a = [1, 2, 3];
// the checked sum of all of the elements of the array
let sum = a.iter().try_fold(0i8, |acc, &x| acc.checked_add(x));
assert_eq!(sum, Some(6));
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::try_fold (line 2351)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::try_fold (line 2351)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 2351,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_588 {
fn main() {
let a = [10, 20, 30, 100, 40, 50];
let mut it = a.iter();
// This sum overflows when adding the 100 element
let sum = it.try_fold(0i8, |acc, &x| acc.checked_add(x));
assert_eq!(sum, None);
// Because it short-circuited, the remaining elements are still
// available through the iterator.
assert_eq!(it.len(), 2);
assert_eq!(it.next(), Some(&40));
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::try_fold (line 2362)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::try_fold (line 2362)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 2362,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_589 {
fn main() {
use std::ops::ControlFlow;
let triangular = (1..30).try_fold(0_i8, |prev, x| {
if let Some(next) = prev.checked_add(x) {
ControlFlow::Continue(next)
} else {
ControlFlow::Break(prev)
}
});
assert_eq!(triangular, ControlFlow::Break(120));
let triangular = (1..30).try_fold(0_u64, |prev, x| {
if let Some(next) = prev.checked_add(x) {
ControlFlow::Continue(next)
} else {
ControlFlow::Break(prev)
}
});
assert_eq!(triangular, ControlFlow::Continue(435));
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::try_fold (line 2379)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::try_fold (line 2379)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 2379,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_590 {
fn main() {
use std::fs::rename;
use std::io::{stdout, Write};
use std::path::Path;
let data = ["no_tea.txt", "stale_bread.json", "torrential_rain.png"];
let res = data.iter().try_for_each(|x| writeln!(stdout(), "{x}"));
assert!(res.is_ok());
let mut it = data.iter().cloned();
let res = it.try_for_each(|x| rename(x, Path::new(x).with_extension("old")));
assert!(res.is_err());
// It short-circuited, so the remaining items are still in the iterator:
assert_eq!(it.next(), Some("stale_bread.json"));
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::try_for_each (line 2427)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::try_for_each (line 2427)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 2427,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_591 {
fn main() {
use std::ops::ControlFlow;
let r = (2..100).try_for_each(|x| {
if 323 % x == 0 {
return ControlFlow::Break(x)
}
ControlFlow::Continue(())
});
assert_eq!(r, ControlFlow::Break(17));
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::try_for_each (line 2447)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::try_for_each (line 2447)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 2447,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_592 {
fn main() {
let a = [(1, 2), (3, 4), (5, 6)];
let (left, right): (Vec<_>, Vec<_>) = a.iter().cloned().unzip();
assert_eq!(left, [1, 3, 5]);
assert_eq!(right, [2, 4, 6]);
// you can also unzip multiple nested tuples at once
let a = [(1, (2, 3)), (4, (5, 6))];
let (x, (y, z)): (Vec<_>, (Vec<_>, Vec<_>)) = a.iter().cloned().unzip();
assert_eq!(x, [1, 4]);
assert_eq!(y, [2, 5]);
assert_eq!(z, [3, 6]);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::unzip (line 3370)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::unzip (line 3370)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 3370,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_593 {
fn main() {
let a1 = [1, 2, 3];
let a2 = [4, 5, 6];
let mut iter = a1.iter().zip(a2.iter());
assert_eq!(iter.next(), Some((&1, &4)));
assert_eq!(iter.next(), Some((&2, &5)));
assert_eq!(iter.next(), Some((&3, &6)));
assert_eq!(iter.next(), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::zip (line 511)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::zip (line 511)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 511,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_594 {
fn main() {
let s1 = &[1, 2, 3];
let s2 = &[4, 5, 6];
let mut iter = s1.iter().zip(s2);
assert_eq!(iter.next(), Some((&1, &4)));
assert_eq!(iter.next(), Some((&2, &5)));
assert_eq!(iter.next(), Some((&3, &6)));
assert_eq!(iter.next(), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::zip (line 528)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::zip (line 528)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 528,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_595 {
fn main() {
let enumerate: Vec<_> = "foo".chars().enumerate().collect();
let zipper: Vec<_> = (0..).zip("foo".chars()).collect();
assert_eq!((0, 'f'), enumerate[0]);
assert_eq!((0, 'f'), zipper[0]);
assert_eq!((1, 'o'), enumerate[1]);
assert_eq!((1, 'o'), zipper[1]);
assert_eq!((2, 'o'), enumerate[2]);
assert_eq!((2, 'o'), zipper[2]);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::zip (line 544)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::zip (line 544)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 544,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_596 {
fn main() {
use std::iter::zip;
let a = [1, 2, 3];
let b = [2, 3, 4];
let mut zipped = zip(
a.into_iter().map(|x| x * 2).skip(1),
b.into_iter().map(|x| x * 2).skip(1),
);
assert_eq!(zipped.next(), Some((4, 6)));
assert_eq!(zipped.next(), Some((6, 8)));
assert_eq!(zipped.next(), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::zip (line 561)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::zip (line 561)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 561,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_597 {
fn main() {
let a = [1, 2, 3];
let b = [2, 3, 4];
let mut zipped = a
.into_iter()
.map(|x| x * 2)
.skip(1)
.zip(b.into_iter().map(|x| x * 2).skip(1));
assert_eq!(zipped.next(), Some((4, 6)));
assert_eq!(zipped.next(), Some((6, 8)));
assert_eq!(zipped.next(), None);
}
#[rustc_test_marker = "library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::zip (line 579)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/iter/traits/iterator.rs - iter::traits::iterator::Iterator::zip (line 579)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/iter/traits/iterator.rs",
start_line: 579,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_598 {
fn main() {
let a = 3;
let b = 1 + 2;
assert_eq!(a, b);
assert_eq!(a, b, "we are testing addition with {} and {}", a, b);
}
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::assert_eq (line 25)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::assert_eq (line 25)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 25,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_599 {
fn main() {
let a = 3;
let b = 2;
assert_ne!(a, b);
assert_ne!(a, b, "we are testing that the values are not equal");
}
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::assert_ne (line 75)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::assert_ne (line 75)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 75,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_600 {
fn main() {
assert!(true);
fn some_computation() -> bool { true } // a very simple function
assert!(some_computation());
// assert with a custom message
let x = true;
assert!(x, "x wasn't true!");
let a = 3; let b = 27;
assert!(a + b == 30, "a = {}, b = {}", a, b);
}
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::builtin::assert (line 1552)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::builtin::assert (line 1552)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 1552,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_601 {
fn main() {
let my_directory = if cfg!(windows) {
"windows-specific-directory"
} else {
"unix-directory"
};
}
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::builtin::cfg (line 1440)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::builtin::cfg (line 1440)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 1440,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_602 {
fn main() {
let current_col = column!();
println!("defined on column: {current_col}");
}
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::builtin::column (line 1243)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::builtin::column (line 1243)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 1243,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_603 {
fn main() {
let a = ("foobar", column!()).1;
let b = ("人之初性本善", column!()).1;
let c = ("f̅o̅o̅b̅a̅r̅", column!()).1; // Uses combining overline (U+0305)
assert_eq!(a, b);
assert_ne!(b, c);
}
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::builtin::column (line 1251)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::builtin::column (line 1251)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 1251,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_604 {
fn main() {
let s = concat!("test", 10, 'b', true);
assert_eq!(s, "test10btrue");
}
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::builtin::concat (line 1191)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::builtin::concat (line 1191)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 1191,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_605 {
fn main() {
let path: &'static str = env!("PATH");
println!("the $PATH variable at the time of compiling was: {path}");
}
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::builtin::env (line 1061)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::builtin::env (line 1061)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 1061,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_606 {
fn main() {
let this_file = file!();
println!("defined in file: {this_file}");
}
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::builtin::file (line 1280)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::builtin::file (line 1280)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 1280,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_607 {
fn main() {
let debug = format!("{:?}", format_args!("{} foo {:?}", 1, 2));
let display = format!("{}", format_args!("{} foo {:?}", 1, 2));
assert_eq!("1 foo 2", display);
assert_eq!(display, debug);
}
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::builtin::format_args (line 973)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::builtin::format_args (line 973)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 973,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_608 {
fn main() {
use std::fmt;
let s = fmt::format(format_args!("hello {}", "world"));
assert_eq!(s, format!("hello {}", "world"));
}
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::builtin::format_args (line 992)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::builtin::format_args (line 992)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 992,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_609 {
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::builtin::include (line 1496)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::builtin::include (line 1496)"),
ignore: true,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 1496,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_610 {
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::builtin::include (line 1506)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::builtin::include (line 1506)"),
ignore: true,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 1506,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_611 {
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::builtin::include_bytes (line 1380)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::builtin::include_bytes (line 1380)"),
ignore: true,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 1380,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_612 {
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::builtin::include_str (line 1340)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::builtin::include_str (line 1340)"),
ignore: true,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 1340,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_613 {
fn main() {
let current_line = line!();
println!("defined on line: {current_line}");
}
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::builtin::line (line 1216)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::builtin::line (line 1216)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 1216,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_614 {
fn main() {
mod test {
pub fn foo() {
assert!(module_path!().ends_with("test"));
}
}
test::foo();
}
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::builtin::module_path (line 1405)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::builtin::module_path (line 1405)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 1405,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_615 {
fn main() {
let key: Option<&'static str> = option_env!("SECRET_KEY");
println!("the secret key might be: {key:?}");
}
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::builtin::option_env (line 1106)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::builtin::option_env (line 1106)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 1106,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_616 {
fn main() {
let one_plus_one = stringify!(1 + 1);
assert_eq!(one_plus_one, "1 + 1");
}
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::builtin::stringify (line 1304)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::builtin::stringify (line 1304)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 1304,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_617 {
fn main() {
debug_assert!(true);
fn some_expensive_computation() -> bool { true } // a very simple function
debug_assert!(some_expensive_computation());
// assert with a custom message
let x = true;
debug_assert!(x, "x wasn't true!");
let a = 3; let b = 27;
debug_assert!(a + b == 30, "a = {}, b = {}", a, b);
}
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::debug_assert (line 295)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::debug_assert (line 295)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 295,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_618 {
fn main() {
let a = 3;
let b = 1 + 2;
debug_assert_eq!(a, b);
}
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::debug_assert_eq (line 336)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::debug_assert_eq (line 336)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 336,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_619 {
fn main() {
let a = 3;
let b = 2;
debug_assert_ne!(a, b);
}
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::debug_assert_ne (line 366)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::debug_assert_ne (line 366)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 366,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_620 {
fn main() {
let foo = 'f';
assert!(matches!(foo, 'A'..='Z' | 'a'..='z'));
let bar = Some(4);
assert!(matches!(bar, Some(x) if x > 2));
}
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::matches (line 445)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::matches (line 445)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 445,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_621 {
fn main() {
#![allow(unreachable_code)]
panic!();
panic!("this is a terrible mistake!");
panic!("this is a {} {message}", "fancy", message = "message");
std::panic::panic_any(4); // panic with the value of 4 to be collected elsewhere
}
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::panic (line 93)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::panic (line 93)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 93,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::Yes,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_622 {
fn main() {
use std::io;
use std::fs::File;
use std::io::prelude::*;
enum MyError {
FileWriteError
}
impl From<io::Error> for MyError {
fn from(e: io::Error) -> MyError {
MyError::FileWriteError
}
}
// The preferred method of quick returning Errors
fn write_to_file_question() -> Result<(), MyError> {
let mut file = File::create("my_best_friends.txt")?;
file.write_all(b"This is a list of my best friends.")?;
Ok(())
}
// The previous method of quick returning Errors
fn write_to_file_using_try() -> Result<(), MyError> {
let mut file = r#try!(File::create("my_best_friends.txt"));
r#try!(file.write_all(b"This is a list of my best friends."));
Ok(())
}
// This is equivalent to:
fn write_to_file_using_match() -> Result<(), MyError> {
let mut file = r#try!(File::create("my_best_friends.txt"));
match file.write_all(b"This is a list of my best friends.") {
Ok(v) => v,
Err(e) => return Err(From::from(e)),
}
Ok(())
}
}
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::r#try (line 487)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::r#try (line 487)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 487,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_623 {
fn main() {
trait Foo {
fn bar(&self) -> u8;
fn baz(&self);
fn qux(&self) -> Result<u64, ()>;
}
}
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::todo (line 848)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::todo (line 848)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 848,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_624 {
trait Foo {
fn bar(&self) -> u8;
fn baz(&self);
fn qux(&self) -> Result<u64, ()>;
}
struct MyStruct;
impl Foo for MyStruct {
fn bar(&self) -> u8 {
1 + 1
}
fn baz(&self) {
// Let's not worry about implementing baz() for now
todo!();
}
fn qux(&self) -> Result<u64, ()> {
// We can add a message to todo! to display our omission.
// This will display:
// "thread 'main' panicked at 'not yet implemented: MyStruct is not yet quxable'".
todo!("MyStruct is not yet quxable");
}
}
fn main() {
let s = MyStruct;
s.bar();
// We aren't even using baz() or qux(), so this is fine.
}
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::todo (line 860)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::todo (line 860)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 860,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_625 {
fn main() {
trait Foo {
fn bar(&self) -> u8;
fn baz(&self);
fn qux(&self) -> Result<u64, ()>;
}
}
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::unimplemented (line 763)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::unimplemented (line 763)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 763,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_626 {
trait Foo {
fn bar(&self) -> u8;
fn baz(&self);
fn qux(&self) -> Result<u64, ()>;
}
struct MyStruct;
impl Foo for MyStruct {
fn bar(&self) -> u8 {
1 + 1
}
fn baz(&self) {
// It makes no sense to `baz` a `MyStruct`, so we have no logic here
// at all.
// This will display "thread 'main' panicked at 'not implemented'".
unimplemented!();
}
fn qux(&self) -> Result<u64, ()> {
// We have some logic here,
// We can add a message to unimplemented! to display our omission.
// This will display:
// "thread 'main' panicked at 'not implemented: MyStruct isn't quxable'".
unimplemented!("MyStruct isn't quxable");
}
}
fn main() {
let s = MyStruct;
s.bar();
}
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::unimplemented (line 779)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::unimplemented (line 779)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 779,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_627 {
fn main() {
#[allow(dead_code)]
fn foo(x: Option<i32>) {
match x {
Some(n) if n >= 0 => println!("Some(Non-negative)"),
Some(n) if n < 0 => println!("Some(Negative)"),
Some(_) => unreachable!(), // compile error if commented out
None => println!("None")
}
}
}
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::unreachable (line 702)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::unreachable (line 702)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 702,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_628 {
fn main() {
#[allow(dead_code)]
fn divide_by_three(x: u32) -> u32 { // one of the poorest implementations of x/3
for i in 0.. {
if 3*i < i { panic!("u32 overflow"); }
if x < 3*i { return i-1; }
}
unreachable!("The loop should always return");
}
}
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::unreachable (line 716)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::unreachable (line 716)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 716,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_629 {
use std::io::Write;
fn main() -> std::io::Result<()> {
let mut w = Vec::new();
write!(&mut w, "test")?;
write!(&mut w, "formatted {}", "arguments")?;
assert_eq!(w, b"testformatted arguments");
Ok(())
}
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::write (line 560)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::write (line 560)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 560,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_630 {
use std::fmt::Write as _;
use std::io::Write as _;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut s = String::new();
let mut v = Vec::new();
write!(&mut s, "{} {}", "abc", 123)?; // uses fmt::Write::write_fmt
write!(&mut v, "s = {:?}", s)?; // uses io::Write::write_fmt
assert_eq!(v, b"s = \"abc 123\"");
Ok(())
}
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::write (line 578)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::write (line 578)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 578,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_631 {
fn main() {
#![allow(unused_imports)]
use std::fmt::{self, Write as _};
use std::io::{self, Write as _};
struct Example;
impl fmt::Write for Example {
fn write_str(&mut self, _s: &str) -> core::fmt::Result {
unimplemented!();
}
}
}
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::write (line 596)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::write (line 596)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 596,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_632 {
fn main() {
use core::fmt::Write;
struct Example;
impl Write for Example {
fn write_str(&mut self, _s: &str) -> core::fmt::Result {
unimplemented!();
}
}
let mut m = Example{};
write!(&mut m, "Hello World").expect("Not written");
}
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::write (line 613)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::write (line 613)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 613,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: true,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_633 {
use std::io::{Write, Result};
fn main() -> Result<()> {
let mut w = Vec::new();
writeln!(&mut w)?;
writeln!(&mut w, "test")?;
writeln!(&mut w, "formatted {}", "arguments")?;
assert_eq!(&w[..], "\ntest\nformatted arguments\n".as_bytes());
Ok(())
}
#[rustc_test_marker = "library/core/src/macros/mod.rs - macros::writeln (line 648)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/macros/mod.rs - macros::writeln (line 648)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/macros/mod.rs",
start_line: 648,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_634 {
fn main() {
#[derive(Debug)]
struct Foo;
let x = Foo;
let y = x;
// `x` has moved into `y`, and so cannot be used
// println!("{x:?}"); // error: use of moved value
}
#[rustc_test_marker = "library/core/src/marker.rs - marker::Copy (line 233)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/marker.rs - marker::Copy (line 233)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/marker.rs",
start_line: 233,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_635 {
fn main() {
#[derive(Debug, Copy, Clone)]
struct Foo;
let x = Foo;
let y = x;
// `y` is a copy of `x`
println!("{x:?}"); // A-OK!
}
#[rustc_test_marker = "library/core/src/marker.rs - marker::Copy (line 248)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/marker.rs - marker::Copy (line 248)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/marker.rs",
start_line: 248,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_636 {
fn main() {
#[derive(Copy, Clone)]
struct MyStruct;
}
#[rustc_test_marker = "library/core/src/marker.rs - marker::Copy (line 271)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/marker.rs - marker::Copy (line 271)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/marker.rs",
start_line: 271,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_637 {
fn main() {
struct MyStruct;
impl Copy for MyStruct { }
impl Clone for MyStruct {
fn clone(&self) -> MyStruct {
*self
}
}
}
#[rustc_test_marker = "library/core/src/marker.rs - marker::Copy (line 278)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/marker.rs - marker::Copy (line 278)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/marker.rs",
start_line: 278,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_638 {
fn main() {
#[allow(dead_code)]
#[derive(Copy, Clone)]
struct Point {
x: i32,
y: i32,
}
}
#[rustc_test_marker = "library/core/src/marker.rs - marker::Copy (line 314)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/marker.rs - marker::Copy (line 314)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/marker.rs",
start_line: 314,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_639 {
fn main() {
#![allow(dead_code)]
struct Point;
struct PointList {
points: Vec<Point>,
}
}
#[rustc_test_marker = "library/core/src/marker.rs - marker::Copy (line 326)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/marker.rs - marker::Copy (line 326)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/marker.rs",
start_line: 326,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_640 {
fn main() {
#![allow(dead_code)]
struct PointList;
#[derive(Copy, Clone)]
struct PointListWrapper<'a> {
point_list_ref: &'a PointList,
}
}
#[rustc_test_marker = "library/core/src/marker.rs - marker::Copy (line 346)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/marker.rs - marker::Copy (line 346)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/marker.rs",
start_line: 346,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_641 {
fn main() {
use std::marker::PhantomData;
#[allow(dead_code)]
struct Slice<'a, T> {
start: *const T,
end: *const T,
phantom: PhantomData<&'a T>,
}
}
#[rustc_test_marker = "library/core/src/marker.rs - marker::PhantomData (line 643)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/marker.rs - marker::PhantomData (line 643)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/marker.rs",
start_line: 643,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_642 {
fn main() {
#![allow(dead_code)]
use std::marker::PhantomData;
struct Slice<'a, T> {
start: *const T,
end: *const T,
phantom: PhantomData<&'a T>,
}
fn borrow_vec<T>(vec: &Vec<T>) -> Slice<'_, T> {
let ptr = vec.as_ptr();
Slice {
start: ptr,
end: unsafe { ptr.add(vec.len()) },
phantom: PhantomData,
}
}
}
#[rustc_test_marker = "library/core/src/marker.rs - marker::PhantomData (line 660)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/marker.rs - marker::PhantomData (line 660)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/marker.rs",
start_line: 660,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_643 {
fn main() {
#![allow(dead_code)]
trait ResType { }
struct ParamType;
mod foreign_lib {
pub fn new(_: usize) -> *mut () { 42 as *mut () }
pub fn do_stuff(_: *mut (), _: usize) {}
}
fn convert_params(_: ParamType) -> usize { 42 }
use std::marker::PhantomData;
use std::mem;
struct ExternalResource<R> {
resource_handle: *mut (),
resource_type: PhantomData<R>,
}
impl<R: ResType> ExternalResource<R> {
fn new() -> Self {
let size_of_res = mem::size_of::<R>();
Self {
resource_handle: foreign_lib::new(size_of_res),
resource_type: PhantomData,
}
}
fn do_stuff(&self, param: ParamType) {
let foreign_params = convert_params(param);
foreign_lib::do_stuff(self.resource_handle, foreign_params);
}
}
}
#[rustc_test_marker = "library/core/src/marker.rs - marker::PhantomData (line 690)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/marker.rs - marker::PhantomData (line 690)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/marker.rs",
start_line: 690,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_644 {
fn main() {
#![allow(dead_code)]
struct Foo<T>(T);
struct Bar<T: ?Sized>(T);
// struct FooUse(Foo<[i32]>); // error: Sized is not implemented for [i32]
struct BarUse(Bar<[i32]>); // OK
}
#[rustc_test_marker = "library/core/src/marker.rs - marker::Sized (line 102)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/marker.rs - marker::Sized (line 102)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/marker.rs",
start_line: 102,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_645 {
fn main() {
#![allow(unused_variables)]
trait Foo { }
trait Bar: Sized { }
struct Impl;
impl Foo for Impl { }
impl Bar for Impl { }
let x: &dyn Foo = &Impl; // OK
// let y: &dyn Bar = &Impl; // error: the trait `Bar` cannot
// be made into an object
}
#[rustc_test_marker = "library/core/src/marker.rs - marker::Sized (line 119)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/marker.rs - marker::Sized (line 119)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/marker.rs",
start_line: 119,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_646 {
fn main() {
#![allow(unused_must_use)]
use std::mem;
use std::pin::Pin;
let mut string = "this".to_string();
let mut pinned_string = Pin::new(&mut string);
// We need a mutable reference to call `mem::replace`.
// We can obtain such a reference by (implicitly) invoking `Pin::deref_mut`,
// but that is only possible because `String` implements `Unpin`.
mem::replace(&mut *pinned_string, "other".to_string());
}
#[rustc_test_marker = "library/core/src/marker.rs - marker::Unpin (line 877)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/marker.rs - marker::Unpin (line 877)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/marker.rs",
start_line: 877,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_647 {
#[rustc_test_marker = "library/core/src/marker.rs - marker::marker_impls (line 18)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/marker.rs - marker::marker_impls (line 18)"),
ignore: true,
ignore_message: None,
source_file: "library/core/src/marker.rs",
start_line: 18,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_648 {
#[rustc_test_marker = "library/core/src/marker.rs - marker::marker_impls (line 22)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/marker.rs - marker::marker_impls (line 22)"),
ignore: true,
ignore_message: None,
source_file: "library/core/src/marker.rs",
start_line: 22,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_649 {
#[rustc_test_marker = "library/core/src/marker.rs - marker::marker_impls (line 26)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/marker.rs - marker::marker_impls (line 26)"),
ignore: true,
ignore_message: None,
source_file: "library/core/src/marker.rs",
start_line: 26,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_650 {
#[rustc_test_marker = "library/core/src/marker.rs - marker::marker_impls (line 34)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/marker.rs - marker::marker_impls (line 34)"),
ignore: true,
ignore_message: None,
source_file: "library/core/src/marker.rs",
start_line: 34,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_651 {
fn main() {
struct Context;
struct Widget {
children: Vec<Widget>,
// `context` will be dropped after `children`.
// Rust guarantees that fields are dropped in the order of declaration.
context: Context,
}
}
#[rustc_test_marker = "library/core/src/mem/manually_drop.rs - mem::manually_drop::ManuallyDrop (line 32)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/manually_drop.rs - mem::manually_drop::ManuallyDrop (line 32)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/manually_drop.rs",
start_line: 32,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_652 {
fn main() {
use std::mem::ManuallyDrop;
let x = ManuallyDrop::new(Box::new(()));
let _: Box<()> = ManuallyDrop::into_inner(x); // This drops the `Box`.
}
#[rustc_test_marker = "library/core/src/mem/manually_drop.rs - mem::manually_drop::ManuallyDrop<T>::into_inner (line 80)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/manually_drop.rs - mem::manually_drop::ManuallyDrop<T>::into_inner (line 80)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/manually_drop.rs",
start_line: 80,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_653 {
fn main() {
use std::mem::ManuallyDrop;
let mut x = ManuallyDrop::new(String::from("Hello World!"));
x.truncate(5); // You can still safely operate on the value
assert_eq!(*x, "Hello");
// But `Drop` will not be run here
}
#[rustc_test_marker = "library/core/src/mem/manually_drop.rs - mem::manually_drop::ManuallyDrop<T>::new (line 59)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/manually_drop.rs - mem::manually_drop::ManuallyDrop<T>::new (line 59)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/manually_drop.rs",
start_line: 59,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_654 {
fn main() {
use std::mem::{self, MaybeUninit};
let data = {
// Create an uninitialized array of `MaybeUninit`.
let mut data: [MaybeUninit<Vec<u32>>; 1000] = [const { MaybeUninit::uninit() }; 1000];
// Dropping a `MaybeUninit` does nothing, so if there is a panic during this loop,
// we have a memory leak, but there is no memory safety issue.
for elem in &mut data[..] {
elem.write(vec![42]);
}
// Everything is initialized. Transmute the array to the
// initialized type.
unsafe { mem::transmute::<_, [Vec<u32>; 1000]>(data) }
};
assert_eq!(&data[0], &[42]);
}
#[rustc_test_marker = "library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit (line 119)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit (line 119)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/maybe_uninit.rs",
start_line: 119,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_655 {
fn main() {
use std::mem::MaybeUninit;
// Create an uninitialized array of `MaybeUninit`.
let mut data: [MaybeUninit<String>; 1000] = [const { MaybeUninit::uninit() }; 1000];
// Count the number of elements we have assigned.
let mut data_len: usize = 0;
for elem in &mut data[0..500] {
elem.write(String::from("hello"));
data_len += 1;
}
// For each item in the array, drop if we allocated it.
for elem in &mut data[0..data_len] {
unsafe { elem.assume_init_drop(); }
}
}
#[rustc_test_marker = "library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit (line 143)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit (line 143)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/maybe_uninit.rs",
start_line: 143,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_656 {
fn main() {
use std::mem::MaybeUninit;
use std::ptr::addr_of_mut;
#[derive(Debug, PartialEq)]
pub struct Foo {
name: String,
list: Vec<u8>,
}
let foo = {
let mut uninit: MaybeUninit<Foo> = MaybeUninit::uninit();
let ptr = uninit.as_mut_ptr();
// Initializing the `name` field
// Using `write` instead of assignment via `=` to not call `drop` on the
// old, uninitialized value.
unsafe { addr_of_mut!((*ptr).name).write("Bob".to_string()); }
// Initializing the `list` field
// If there is a panic here, then the `String` in the `name` field leaks.
unsafe { addr_of_mut!((*ptr).list).write(vec![0, 1, 2]); }
// All the fields are initialized, so we call `assume_init` to get an initialized Foo.
unsafe { uninit.assume_init() }
};
assert_eq!(
foo,
Foo {
name: "Bob".to_string(),
list: vec![0, 1, 2]
}
);
}
#[rustc_test_marker = "library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit (line 166)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit (line 166)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/maybe_uninit.rs",
start_line: 166,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_657 {
fn main() {
#![allow(invalid_value)]
use std::mem::{self, MaybeUninit};
let x: &i32 = unsafe { mem::zeroed() }; // undefined behavior! ⚠️
// The equivalent code with `MaybeUninit<&i32>`:
let x: &i32 = unsafe { MaybeUninit::zeroed().assume_init() }; // undefined behavior! ⚠️
}
#[rustc_test_marker = "library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit (line 19)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit (line 19)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/maybe_uninit.rs",
start_line: 19,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: true,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_658 {
fn main() {
use std::mem::{MaybeUninit, size_of, align_of};
assert_eq!(size_of::<MaybeUninit<u64>>(), size_of::<u64>());
assert_eq!(align_of::<MaybeUninit<u64>>(), align_of::<u64>());
}
#[rustc_test_marker = "library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit (line 208)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit (line 208)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/maybe_uninit.rs",
start_line: 208,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_659 {
fn main() {
use std::mem::{MaybeUninit, size_of};
assert_eq!(size_of::<Option<bool>>(), 1);
assert_eq!(size_of::<Option<MaybeUninit<bool>>>(), 2);
}
#[rustc_test_marker = "library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit (line 220)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit (line 220)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/maybe_uninit.rs",
start_line: 220,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_660 {
fn main() {
#![allow(invalid_value)]
use std::mem::{self, MaybeUninit};
let b: bool = unsafe { mem::uninitialized() }; // undefined behavior! ⚠️
// The equivalent code with `MaybeUninit<bool>`:
let b: bool = unsafe { MaybeUninit::uninit().assume_init() }; // undefined behavior! ⚠️
}
#[rustc_test_marker = "library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit (line 34)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit (line 34)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/maybe_uninit.rs",
start_line: 34,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: true,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_661 {
fn main() {
#![allow(invalid_value)]
use std::mem::{self, MaybeUninit};
let x: i32 = unsafe { mem::uninitialized() }; // undefined behavior! ⚠️
// The equivalent code with `MaybeUninit<i32>`:
let x: i32 = unsafe { MaybeUninit::uninit().assume_init() }; // undefined behavior! ⚠️
}
#[rustc_test_marker = "library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit (line 49)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit (line 49)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/maybe_uninit.rs",
start_line: 49,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: true,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_662 {
fn main() {
use std::mem::MaybeUninit;
// Create an explicitly uninitialized reference. The compiler knows that data inside
// a `MaybeUninit<T>` may be invalid, and hence this is not UB:
let mut x = MaybeUninit::<&i32>::uninit();
// Set it to a valid value.
x.write(&0);
// Extract the initialized data -- this is only allowed *after* properly
// initializing `x`!
let x = unsafe { x.assume_init() };
}
#[rustc_test_marker = "library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit (line 73)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit (line 73)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/maybe_uninit.rs",
start_line: 73,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_663 {
fn main() {
use std::mem::MaybeUninit;
unsafe fn make_vec(out: *mut Vec<i32>) {
// `write` does not drop the old contents, which is important.
out.write(vec![1, 2, 3]);
}
let mut v = MaybeUninit::uninit();
unsafe { make_vec(v.as_mut_ptr()); }
// Now we know `v` is initialized! This also makes sure the vector gets
// properly dropped.
let v = unsafe { v.assume_init() };
assert_eq!(&v, &[1, 2, 3]);
}
#[rustc_test_marker = "library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit (line 99)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit (line 99)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/maybe_uninit.rs",
start_line: 99,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_664 {
fn main() {
use std::mem::MaybeUninit;
let mut x = MaybeUninit::<Vec<u32>>::uninit();
x.write(vec![0, 1, 2]);
// Create a reference into the `MaybeUninit<Vec<u32>>`.
// This is okay because we initialized it.
let x_vec = unsafe { &mut *x.as_mut_ptr() };
x_vec.push(3);
assert_eq!(x_vec.len(), 4);
}
#[rustc_test_marker = "library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::as_mut_ptr (line 538)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::as_mut_ptr (line 538)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/maybe_uninit.rs",
start_line: 538,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_665 {
fn main() {
use std::mem::MaybeUninit;
let mut x = MaybeUninit::<Vec<u32>>::uninit();
let x_vec = unsafe { &mut *x.as_mut_ptr() };
// We have created a reference to an uninitialized vector! This is undefined behavior. ⚠️
}
#[rustc_test_marker = "library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::as_mut_ptr (line 552)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::as_mut_ptr (line 552)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/maybe_uninit.rs",
start_line: 552,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: true,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_666 {
fn main() {
use std::mem::MaybeUninit;
let mut x = MaybeUninit::<Vec<u32>>::uninit();
x.write(vec![0, 1, 2]);
// Create a reference into the `MaybeUninit<T>`. This is okay because we initialized it.
let x_vec = unsafe { &*x.as_ptr() };
assert_eq!(x_vec.len(), 3);
}
#[rustc_test_marker = "library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::as_ptr (line 501)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::as_ptr (line 501)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/maybe_uninit.rs",
start_line: 501,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_667 {
fn main() {
use std::mem::MaybeUninit;
let x = MaybeUninit::<Vec<u32>>::uninit();
let x_vec = unsafe { &*x.as_ptr() };
// We have created a reference to an uninitialized vector! This is undefined behavior. ⚠️
}
#[rustc_test_marker = "library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::as_ptr (line 513)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::as_ptr (line 513)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/maybe_uninit.rs",
start_line: 513,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: true,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_668 {
fn main() {
use std::mem::MaybeUninit;
let mut x = MaybeUninit::<bool>::uninit();
x.write(true);
let x_init = unsafe { x.assume_init() };
assert_eq!(x_init, true);
}
#[rustc_test_marker = "library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::assume_init (line 597)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::assume_init (line 597)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/maybe_uninit.rs",
start_line: 597,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_669 {
fn main() {
use std::mem::MaybeUninit;
let x = MaybeUninit::<Vec<u32>>::uninit();
let x_init = unsafe { x.assume_init() };
// `x` had not been initialized yet, so this last line caused undefined behavior. ⚠️
}
#[rustc_test_marker = "library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::assume_init (line 608)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::assume_init (line 608)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/maybe_uninit.rs",
start_line: 608,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: true,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_670 {
fn main() {
#![allow(unexpected_cfgs)]
use std::mem::MaybeUninit;
unsafe extern "C" fn initialize_buffer(buf: *mut [u8; 1024]) { *buf = [0; 1024] }
#[cfg(FALSE)]
extern "C" {
/// Initializes *all* the bytes of the input buffer.
fn initialize_buffer(buf: *mut [u8; 1024]);
}
let mut buf = MaybeUninit::<[u8; 1024]>::uninit();
// Initialize `buf`:
unsafe { initialize_buffer(buf.as_mut_ptr()); }
// Now we know that `buf` has been initialized, so we could `.assume_init()` it.
// However, using `.assume_init()` may trigger a `memcpy` of the 1024 bytes.
// To assert our buffer has been initialized without copying it, we upgrade
// the `&mut MaybeUninit<[u8; 1024]>` to a `&mut [u8; 1024]`:
let buf: &mut [u8; 1024] = unsafe {
// SAFETY: `buf` has been initialized.
buf.assume_init_mut()
};
// Now we can use `buf` as a normal slice:
buf.sort_unstable();
assert!(
buf.windows(2).all(|pair| pair[0] <= pair[1]),
"buffer is sorted",
);
}
#[rustc_test_marker = "library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::assume_init_mut (line 810)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::assume_init_mut (line 810)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/maybe_uninit.rs",
start_line: 810,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_671 {
fn main() {
use std::mem::MaybeUninit;
let mut b = MaybeUninit::<bool>::uninit();
unsafe {
*b.assume_init_mut() = true;
// We have created a (mutable) reference to an uninitialized `bool`!
// This is undefined behavior. ⚠️
}
}
#[rustc_test_marker = "library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::assume_init_mut (line 846)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::assume_init_mut (line 846)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/maybe_uninit.rs",
start_line: 846,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: true,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_672 {
fn main() {
use std::{io, mem::MaybeUninit};
fn read_chunk (reader: &'_ mut dyn io::Read) -> io::Result<[u8; 64]>
{
let mut buffer = MaybeUninit::<[u8; 64]>::uninit();
reader.read_exact(unsafe { buffer.assume_init_mut() })?;
// ^^^^^^^^^^^^^^^^^^^^^^^^
// (mutable) reference to uninitialized memory!
// This is undefined behavior.
Ok(unsafe { buffer.assume_init() })
}
}
#[rustc_test_marker = "library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::assume_init_mut (line 861)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::assume_init_mut (line 861)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/maybe_uninit.rs",
start_line: 861,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: true,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_673 {
fn main() {
use std::{mem::MaybeUninit, ptr};
struct Foo {
a: u32,
b: u8,
}
let foo: Foo = unsafe {
let mut foo = MaybeUninit::<Foo>::uninit();
ptr::write(&mut foo.assume_init_mut().a as *mut u32, 1337);
// ^^^^^^^^^^^^^^^^^^^^^
// (mutable) reference to uninitialized memory!
// This is undefined behavior.
ptr::write(&mut foo.assume_init_mut().b as *mut u8, 42);
// ^^^^^^^^^^^^^^^^^^^^^
// (mutable) reference to uninitialized memory!
// This is undefined behavior.
foo.assume_init()
};
}
#[rustc_test_marker = "library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::assume_init_mut (line 877)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::assume_init_mut (line 877)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/maybe_uninit.rs",
start_line: 877,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: true,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_674 {
fn main() {
use std::mem::MaybeUninit;
let mut x = MaybeUninit::<u32>::uninit();
x.write(13);
let x1 = unsafe { x.assume_init_read() };
// `u32` is `Copy`, so we may read multiple times.
let x2 = unsafe { x.assume_init_read() };
assert_eq!(x1, x2);
let mut x = MaybeUninit::<Option<Vec<u32>>>::uninit();
x.write(None);
let x1 = unsafe { x.assume_init_read() };
// Duplicating a `None` value is okay, so we may read multiple times.
let x2 = unsafe { x.assume_init_read() };
assert_eq!(x1, x2);
}
#[rustc_test_marker = "library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::assume_init_read (line 656)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::assume_init_read (line 656)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/maybe_uninit.rs",
start_line: 656,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_675 {
fn main() {
use std::mem::MaybeUninit;
let mut x = MaybeUninit::<Option<Vec<u32>>>::uninit();
x.write(Some(vec![0, 1, 2]));
let x1 = unsafe { x.assume_init_read() };
let x2 = unsafe { x.assume_init_read() };
// We now created two copies of the same vector, leading to a double-free ⚠️ when
// they both get dropped!
}
#[rustc_test_marker = "library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::assume_init_read (line 676)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::assume_init_read (line 676)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/maybe_uninit.rs",
start_line: 676,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: true,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_676 {
fn main() {
use std::mem::MaybeUninit;
let mut x = MaybeUninit::<Vec<u32>>::uninit();
// Initialize `x`:
x.write(vec![1, 2, 3]);
// Now that our `MaybeUninit<_>` is known to be initialized, it is okay to
// create a shared reference to it:
let x: &Vec<u32> = unsafe {
// SAFETY: `x` has been initialized.
x.assume_init_ref()
};
assert_eq!(x, &vec![1, 2, 3]);
}
#[rustc_test_marker = "library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::assume_init_ref (line 745)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::assume_init_ref (line 745)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/maybe_uninit.rs",
start_line: 745,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_677 {
fn main() {
use std::mem::MaybeUninit;
let x = MaybeUninit::<Vec<u32>>::uninit();
let x_vec: &Vec<u32> = unsafe { x.assume_init_ref() };
// We have created a reference to an uninitialized vector! This is undefined behavior. ⚠️
}
#[rustc_test_marker = "library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::assume_init_ref (line 762)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::assume_init_ref (line 762)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/maybe_uninit.rs",
start_line: 762,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: true,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_678 {
fn main() {
use std::{cell::Cell, mem::MaybeUninit};
let b = MaybeUninit::<Cell<bool>>::uninit();
// Initialize the `MaybeUninit` using `Cell::set`:
unsafe {
b.assume_init_ref().set(true);
// ^^^^^^^^^^^^^^^
// Reference to an uninitialized `Cell<bool>`: UB!
}
}
#[rustc_test_marker = "library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::assume_init_ref (line 770)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::assume_init_ref (line 770)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/maybe_uninit.rs",
start_line: 770,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: true,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_679 {
fn main() {
use std::mem::MaybeUninit;
let v: MaybeUninit<Vec<u8>> = MaybeUninit::new(vec![42]);
}
#[rustc_test_marker = "library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::new (line 273)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::new (line 273)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/maybe_uninit.rs",
start_line: 273,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_680 {
fn main() {
use std::mem::MaybeUninit;
let v: MaybeUninit<String> = MaybeUninit::uninit();
}
#[rustc_test_marker = "library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::uninit (line 297)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::uninit (line 297)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/maybe_uninit.rs",
start_line: 297,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_681 {
fn main() {
use std::mem::MaybeUninit;
let mut x = MaybeUninit::<Vec<u8>>::uninit();
{
let hello = x.write((&b"Hello, world!").to_vec());
// Setting hello does not leak prior allocations, but drops them
*hello = (&b"Hello").to_vec();
hello[0] = 'h' as u8;
}
// x is initialized now:
let s = unsafe { x.assume_init() };
assert_eq!(b"hello", s.as_slice());
}
#[rustc_test_marker = "library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::write (line 425)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::write (line 425)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/maybe_uninit.rs",
start_line: 425,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_682 {
fn main() {
use std::mem::MaybeUninit;
let mut x = MaybeUninit::<String>::uninit();
x.write("Hello".to_string());
// This leaks the contained string:
x.write("hello".to_string());
// x is initialized now:
let s = unsafe { x.assume_init() };
}
#[rustc_test_marker = "library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::write (line 443)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::write (line 443)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/maybe_uninit.rs",
start_line: 443,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_683 {
fn main() {
use core::pin::Pin;
use core::mem::MaybeUninit;
struct PinArena<T> {
memory: Box<[MaybeUninit<T>]>,
len: usize,
}
impl <T> PinArena<T> {
pub fn capacity(&self) -> usize {
self.memory.len()
}
pub fn push(&mut self, val: T) -> Pin<&mut T> {
if self.len >= self.capacity() {
panic!("Attempted to push to a full pin arena!");
}
let ref_ = self.memory[self.len].write(val);
self.len += 1;
unsafe { Pin::new_unchecked(ref_) }
}
}
}
#[rustc_test_marker = "library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::write (line 460)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::write (line 460)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/maybe_uninit.rs",
start_line: 460,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_684 {
fn main() {
use std::mem::MaybeUninit;
let x = MaybeUninit::<(u8, bool)>::zeroed();
let x = unsafe { x.assume_init() };
assert_eq!(x, (0, false));
}
#[rustc_test_marker = "library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::zeroed (line 362)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::zeroed (line 362)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/maybe_uninit.rs",
start_line: 362,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_685 {
fn main() {
use std::mem::MaybeUninit;
enum NotZero { One = 1, Two = 2 }
let x = MaybeUninit::<(u8, NotZero)>::zeroed();
let x = unsafe { x.assume_init() };
// Inside a pair, we create a `NotZero` that does not have a valid discriminant.
// This is undefined behavior. ⚠️
}
#[rustc_test_marker = "library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::zeroed (line 376)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/maybe_uninit.rs - mem::maybe_uninit::MaybeUninit<T>::zeroed (line 376)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/maybe_uninit.rs",
start_line: 376,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: true,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_686 {
fn main() {
use std::mem;
assert_eq!(4, mem::align_of::<i32>());
}
#[rustc_test_marker = "library/core/src/mem/mod.rs - mem::align_of (line 455)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/mod.rs - mem::align_of (line 455)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/mod.rs",
start_line: 455,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_687 {
fn main() {
use std::mem;
assert_eq!(4, mem::align_of_val(&5i32));
}
#[rustc_test_marker = "library/core/src/mem/mod.rs - mem::align_of_val (line 478)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/mod.rs - mem::align_of_val (line 478)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/mod.rs",
start_line: 478,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_688 {
fn main() {
pub fn copy<T: Copy>(x: &T) -> T { *x }
}
#[rustc_test_marker = "library/core/src/mem/mod.rs - mem::copy (line 943)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/mod.rs - mem::copy (line 943)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/mod.rs",
start_line: 943,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_689 {
fn main() {
use std::mem;
enum Foo { A(&'static str), B(i32), C(i32) }
assert_eq!(mem::discriminant(&Foo::A("bar")), mem::discriminant(&Foo::A("baz")));
assert_eq!(mem::discriminant(&Foo::B(1)), mem::discriminant(&Foo::B(2)));
assert_ne!(mem::discriminant(&Foo::B(3)), mem::discriminant(&Foo::C(3)));
}
#[rustc_test_marker = "library/core/src/mem/mod.rs - mem::discriminant (line 1093)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/mod.rs - mem::discriminant (line 1093)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/mod.rs",
start_line: 1093,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_690 {
fn main() {
enum Enum {
Foo,
Bar,
Baz,
}
assert_eq!(0, Enum::Foo as isize);
assert_eq!(1, Enum::Bar as isize);
assert_eq!(2, Enum::Baz as isize);
}
#[rustc_test_marker = "library/core/src/mem/mod.rs - mem::discriminant (line 1110)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/mod.rs - mem::discriminant (line 1110)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/mod.rs",
start_line: 1110,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_691 {
fn main() {
#[repr(u8)]
enum Enum {
Unit,
Tuple(bool),
Struct { a: bool },
}
impl Enum {
fn discriminant(&self) -> u8 {
// SAFETY: Because `Self` is marked `repr(u8)`, its layout is a `repr(C)` `union`
// between `repr(C)` structs, each of which has the `u8` discriminant as its first
// field, so we can read the discriminant without offsetting the pointer.
unsafe { *<*const _>::from(self).cast::<u8>() }
}
}
let unit_like = Enum::Unit;
let tuple_like = Enum::Tuple(true);
let struct_like = Enum::Struct { a: false };
assert_eq!(0, unit_like.discriminant());
assert_eq!(1, tuple_like.discriminant());
assert_eq!(2, struct_like.discriminant());
// ⚠️ This is undefined behavior. Don't do this. ⚠️
// assert_eq!(0, unsafe { std::mem::transmute::<_, u8>(std::mem::discriminant(&unit_like)) });
}
#[rustc_test_marker = "library/core/src/mem/mod.rs - mem::discriminant (line 1131)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/mod.rs - mem::discriminant (line 1131)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/mod.rs",
start_line: 1131,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_692 {
fn main() {
pub fn drop<T>(_x: T) {}
}
#[rustc_test_marker = "library/core/src/mem/mod.rs - mem::drop (line 883)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/mod.rs - mem::drop (line 883)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/mod.rs",
start_line: 883,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_693 {
fn main() {
let v = vec![1, 2, 3];
drop(v); // explicitly drop the vector
}
#[rustc_test_marker = "library/core/src/mem/mod.rs - mem::drop (line 896)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/mod.rs - mem::drop (line 896)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/mod.rs",
start_line: 896,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_694 {
fn main() {
use std::cell::RefCell;
let x = RefCell::new(1);
let mut mutable_borrow = x.borrow_mut();
*mutable_borrow = 1;
drop(mutable_borrow); // relinquish the mutable borrow on this slot
let borrow = x.borrow();
println!("{}", *borrow);
}
#[rustc_test_marker = "library/core/src/mem/mod.rs - mem::drop (line 905)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/mod.rs - mem::drop (line 905)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/mod.rs",
start_line: 905,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_695 {
fn main() {
#![allow(dropping_copy_types)]
#[derive(Copy, Clone)]
struct Foo(u8);
let x = 1;
let y = Foo(2);
drop(x); // a copy of `x` is moved and dropped
drop(y); // a copy of `y` is moved and dropped
println!("x: {}, y: {}", x, y.0); // still available
}
#[rustc_test_marker = "library/core/src/mem/mod.rs - mem::drop (line 921)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/mod.rs - mem::drop (line 921)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/mod.rs",
start_line: 921,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_696 {
fn main() {
use std::mem::ManuallyDrop;
let v = vec![65, 122];
// Before we disassemble `v` into its raw parts, make sure it
// does not get dropped!
let mut v = ManuallyDrop::new(v);
// Now disassemble `v`. These operations cannot panic, so there cannot be a leak.
let (ptr, len, cap) = (v.as_mut_ptr(), v.len(), v.capacity());
// Finally, build a `String`.
let s = unsafe { String::from_raw_parts(ptr, len, cap) };
assert_eq!(s, "Az");
// `s` is implicitly dropped and its memory deallocated.
}
#[rustc_test_marker = "library/core/src/mem/mod.rs - mem::forget (line 112)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/mod.rs - mem::forget (line 112)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/mod.rs",
start_line: 112,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_697 {
fn main() {
use std::mem;
use std::fs::File;
let file = File::open("foo.txt").unwrap();
mem::forget(file);
}
#[rustc_test_marker = "library/core/src/mem/mod.rs - mem::forget (line 69)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/mod.rs - mem::forget (line 69)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/mod.rs",
start_line: 69,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: true,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_698 {
fn main() {
use std::mem;
let mut v = vec![65, 122];
// Build a `String` using the contents of `v`
let s = unsafe { String::from_raw_parts(v.as_mut_ptr(), v.len(), v.capacity()) };
// leak `v` because its memory is now managed by `s`
mem::forget(v); // ERROR - v is invalid and must not be passed to a function
assert_eq!(s, "Az");
// `s` is implicitly dropped and its memory deallocated.
}
#[rustc_test_marker = "library/core/src/mem/mod.rs - mem::forget (line 86)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/mod.rs - mem::forget (line 86)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/mod.rs",
start_line: 86,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_699 {
fn main() {
#![allow(deprecated)]
use std::mem;
assert_eq!(4, mem::min_align_of::<i32>());
}
#[rustc_test_marker = "library/core/src/mem/mod.rs - mem::min_align_of (line 407)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/mod.rs - mem::min_align_of (line 407)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/mod.rs",
start_line: 407,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_700 {
fn main() {
#![allow(deprecated)]
use std::mem;
assert_eq!(4, mem::min_align_of_val(&5i32));
}
#[rustc_test_marker = "library/core/src/mem/mod.rs - mem::min_align_of_val (line 430)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/mod.rs - mem::min_align_of_val (line 430)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/mod.rs",
start_line: 430,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_701 {
fn main() {
use std::{mem, ptr};
pub struct MyCollection<T> {
data: [T; 1],
/* ... */
}
impl<T> MyCollection<T> {
fn iter_mut(&mut self) -> &mut [T] { &mut self.data }
fn free_buffer(&mut self) {}
}
impl<T> Drop for MyCollection<T> {
fn drop(&mut self) {
unsafe {
// drop the data
if mem::needs_drop::<T>() {
for x in self.iter_mut() {
ptr::drop_in_place(x);
}
}
self.free_buffer();
}
}
}
}
#[rustc_test_marker = "library/core/src/mem/mod.rs - mem::needs_drop (line 569)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/mod.rs - mem::needs_drop (line 569)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/mod.rs",
start_line: 569,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_702 {
fn main() {
mod nested {
#[repr(C)]
pub struct Struct {
private: u8,
}
}
// assert_eq!(mem::offset_of!(nested::Struct, private), 0);
// ^^^ error[E0616]: field `private` of struct `Struct` is private
}
#[rustc_test_marker = "library/core/src/mem/mod.rs - mem::offset_of (line 1257)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/mod.rs - mem::offset_of (line 1257)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/mod.rs",
start_line: 1257,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_703 {
fn main() {
struct Wrapper<T, U>(T, U);
type A = Wrapper<u8, u8>;
type B = Wrapper<u8, i8>;
// Not necessarily identical even though `u8` and `i8` have the same layout!
// assert_eq!(mem::offset_of!(A, 1), mem::offset_of!(B, 1));
#[repr(transparent)]
struct U8(u8);
type C = Wrapper<u8, U8>;
// Not necessarily identical even though `u8` and `U8` have the same layout!
// assert_eq!(mem::offset_of!(A, 1), mem::offset_of!(C, 1));
struct Empty<T>(core::marker::PhantomData<T>);
// Not necessarily identical even though `PhantomData` always has the same layout!
// assert_eq!(mem::offset_of!(Empty<u8>, 0), mem::offset_of!(Empty<i8>, 0));
}
#[rustc_test_marker = "library/core/src/mem/mod.rs - mem::offset_of (line 1279)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/mod.rs - mem::offset_of (line 1279)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/mod.rs",
start_line: 1279,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_704 {
fn main() {
use std::mem;
let mut v: Vec<i32> = vec![1, 2];
let old_v = mem::replace(&mut v, vec![3, 4, 5]);
assert_eq!(vec![1, 2], old_v);
assert_eq!(vec![3, 4, 5], v);
}
#[rustc_test_marker = "library/core/src/mem/mod.rs - mem::replace (line 806)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/mod.rs - mem::replace (line 806)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/mod.rs",
start_line: 806,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_705 {
fn main() {
#![allow(dead_code)]
use std::mem;
struct Buffer<T> { buf: Vec<T> }
impl<T> Buffer<T> {
fn replace_index(&mut self, i: usize, v: T) -> T {
mem::replace(&mut self.buf[i], v)
}
}
let mut buffer = Buffer { buf: vec![0, 1] };
assert_eq!(buffer.buf[0], 0);
assert_eq!(buffer.replace_index(0, 2), 0);
assert_eq!(buffer.buf[0], 2);
}
#[rustc_test_marker = "library/core/src/mem/mod.rs - mem::replace (line 836)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/mod.rs - mem::replace (line 836)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/mod.rs",
start_line: 836,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_706 {
fn main() {
use std::mem;
// Some primitives
assert_eq!(4, mem::size_of::<i32>());
assert_eq!(8, mem::size_of::<f64>());
assert_eq!(0, mem::size_of::<()>());
// Some arrays
assert_eq!(8, mem::size_of::<[i32; 2]>());
assert_eq!(12, mem::size_of::<[i32; 3]>());
assert_eq!(0, mem::size_of::<[i32; 0]>());
// Pointer size equality
assert_eq!(mem::size_of::<&i32>(), mem::size_of::<*const i32>());
assert_eq!(mem::size_of::<&i32>(), mem::size_of::<Box<i32>>());
assert_eq!(mem::size_of::<&i32>(), mem::size_of::<Option<&i32>>());
assert_eq!(mem::size_of::<Box<i32>>(), mem::size_of::<Option<Box<i32>>>());
}
#[rustc_test_marker = "library/core/src/mem/mod.rs - mem::size_of (line 232)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/mod.rs - mem::size_of (line 232)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/mod.rs",
start_line: 232,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_707 {
fn main() {
use std::mem;
#[repr(C)]
struct FieldStruct {
first: u8,
second: u16,
third: u8
}
// The size of the first field is 1, so add 1 to the size. Size is 1.
// The alignment of the second field is 2, so add 1 to the size for padding. Size is 2.
// The size of the second field is 2, so add 2 to the size. Size is 4.
// The alignment of the third field is 1, so add 0 to the size for padding. Size is 4.
// The size of the third field is 1, so add 1 to the size. Size is 5.
// Finally, the alignment of the struct is 2 (because the largest alignment amongst its
// fields is 2), so add 1 to the size for padding. Size is 6.
assert_eq!(6, mem::size_of::<FieldStruct>());
#[repr(C)]
struct TupleStruct(u8, u16, u8);
// Tuple structs follow the same rules.
assert_eq!(6, mem::size_of::<TupleStruct>());
// Note that reordering the fields can lower the size. We can remove both padding bytes
// by putting `third` before `second`.
#[repr(C)]
struct FieldStructOptimized {
first: u8,
third: u8,
second: u16
}
assert_eq!(4, mem::size_of::<FieldStructOptimized>());
// Union size is the size of the largest field.
#[repr(C)]
union ExampleUnion {
smaller: u8,
larger: u16
}
assert_eq!(2, mem::size_of::<ExampleUnion>());
}
#[rustc_test_marker = "library/core/src/mem/mod.rs - mem::size_of (line 255)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/mod.rs - mem::size_of (line 255)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/mod.rs",
start_line: 255,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_708 {
fn main() {
use std::mem;
assert_eq!(4, mem::size_of_val(&5i32));
let x: [u8; 13] = [0; 13];
let y: &[u8] = &x;
assert_eq!(13, mem::size_of_val(y));
}
#[rustc_test_marker = "library/core/src/mem/mod.rs - mem::size_of_val (line 326)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/mod.rs - mem::size_of_val (line 326)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/mod.rs",
start_line: 326,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_709 {
fn main() {
use std::mem;
let mut x = 5;
let mut y = 42;
mem::swap(&mut x, &mut y);
assert_eq!(42, x);
assert_eq!(5, y);
}
#[rustc_test_marker = "library/core/src/mem/mod.rs - mem::swap (line 713)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/mod.rs - mem::swap (line 713)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/mod.rs",
start_line: 713,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_710 {
fn main() {
use std::mem;
let mut v: Vec<i32> = vec![1, 2];
let old_v = mem::take(&mut v);
assert_eq!(vec![1, 2], old_v);
assert!(v.is_empty());
}
#[rustc_test_marker = "library/core/src/mem/mod.rs - mem::take (line 743)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/mod.rs - mem::take (line 743)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/mod.rs",
start_line: 743,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_711 {
fn main() {
use std::mem;
struct Buffer<T> { buf: Vec<T> }
impl<T> Buffer<T> {
fn get_and_reset(&mut self) -> Vec<T> {
mem::take(&mut self.buf)
}
}
let mut buffer = Buffer { buf: vec![0, 1] };
assert_eq!(buffer.buf.len(), 2);
assert_eq!(buffer.get_and_reset(), vec![0, 1]);
assert_eq!(buffer.buf.len(), 0);
}
#[rustc_test_marker = "library/core/src/mem/mod.rs - mem::take (line 773)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/mod.rs - mem::take (line 773)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/mod.rs",
start_line: 773,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_712 {
fn main() {
use std::mem;
#[repr(packed)]
struct Foo {
bar: u8,
}
let foo_array = [10u8];
unsafe {
// Copy the data from 'foo_array' and treat it as a 'Foo'
let mut foo_struct: Foo = mem::transmute_copy(&foo_array);
assert_eq!(foo_struct.bar, 10);
// Modify the copied data
foo_struct.bar = 20;
assert_eq!(foo_struct.bar, 20);
}
// The contents of 'foo_array' should not have changed
assert_eq!(foo_array, [10]);
}
#[rustc_test_marker = "library/core/src/mem/mod.rs - mem::transmute_copy (line 979)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/mod.rs - mem::transmute_copy (line 979)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/mod.rs",
start_line: 979,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_713 {
fn main() {
use std::mem;
let x: i32 = unsafe { mem::zeroed() };
assert_eq!(0, x);
}
#[rustc_test_marker = "library/core/src/mem/mod.rs - mem::zeroed (line 627)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/mod.rs - mem::zeroed (line 627)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/mod.rs",
start_line: 627,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_714 {
fn main() {
#![allow(invalid_value)]
use std::mem;
let _x: &i32 = unsafe { mem::zeroed() }; // Undefined behavior!
let _y: fn() = unsafe { mem::zeroed() }; // And again!
}
#[rustc_test_marker = "library/core/src/mem/mod.rs - mem::zeroed (line 636)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/mem/mod.rs - mem::zeroed (line 636)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/mem/mod.rs",
start_line: 636,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: true,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(Ok::<(), String>(())),
)
};
}
mod __doctest_715 {
fn main() {
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
let localhost_v4 = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1));
let localhost_v6 = IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1));
assert_eq!("127.0.0.1".parse(), Ok(localhost_v4));
assert_eq!("::1".parse(), Ok(localhost_v6));
assert_eq!(localhost_v4.is_ipv6(), false);
assert_eq!(localhost_v4.is_ipv4(), true);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::IpAddr (line 16)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::IpAddr (line 16)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 16,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_716 {
fn main() {
use std::net::{IpAddr, Ipv4Addr};
let addr = Ipv4Addr::new(127, 0, 0, 1);
assert_eq!(
IpAddr::V4(addr),
IpAddr::from(addr)
)
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::IpAddr::from (line 1018)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::IpAddr::from (line 1018)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 1018,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_717 {
fn main() {
use std::net::{IpAddr, Ipv6Addr};
let addr = Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff);
assert_eq!(
IpAddr::V6(addr),
IpAddr::from(addr)
);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::IpAddr::from (line 1040)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::IpAddr::from (line 1040)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 1040,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_718 {
fn main() {
use std::net::{IpAddr, Ipv4Addr};
let addr = IpAddr::from([13u8, 12u8, 11u8, 10u8]);
assert_eq!(IpAddr::V4(Ipv4Addr::new(13, 12, 11, 10)), addr);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::IpAddr::from (line 1186)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::IpAddr::from (line 1186)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 1186,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_719 {
fn main() {
use std::net::{IpAddr, Ipv6Addr};
let addr = IpAddr::from([
25u8, 24u8, 23u8, 22u8, 21u8, 20u8, 19u8, 18u8,
17u8, 16u8, 15u8, 14u8, 13u8, 12u8, 11u8, 10u8,
]);
assert_eq!(
IpAddr::V6(Ipv6Addr::new(
0x1918, 0x1716,
0x1514, 0x1312,
0x1110, 0x0f0e,
0x0d0c, 0x0b0a
)),
addr
);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::IpAddr::from (line 2147)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::IpAddr::from (line 2147)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 2147,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_720 {
fn main() {
use std::net::{IpAddr, Ipv6Addr};
let addr = IpAddr::from([
525u16, 524u16, 523u16, 522u16,
521u16, 520u16, 519u16, 518u16,
]);
assert_eq!(
IpAddr::V6(Ipv6Addr::new(
0x20d, 0x20c,
0x20b, 0x20a,
0x209, 0x208,
0x207, 0x206
)),
addr
);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::IpAddr::from (line 2176)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::IpAddr::from (line 2176)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 2176,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_721 {
fn main() {
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
assert_eq!(IpAddr::V4(Ipv4Addr::new(203, 0, 113, 6)).is_ipv4(), true);
assert_eq!(IpAddr::V6(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0)).is_ipv4(), false);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::IpAddr::is_ipv4 (line 374)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::IpAddr::is_ipv4 (line 374)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 374,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_722 {
fn main() {
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
assert_eq!(IpAddr::V4(Ipv4Addr::new(203, 0, 113, 6)).is_ipv6(), false);
assert_eq!(IpAddr::V6(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0)).is_ipv6(), true);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::IpAddr::is_ipv6 (line 395)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::IpAddr::is_ipv6 (line 395)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 395,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_723 {
fn main() {
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
assert_eq!(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)).is_loopback(), true);
assert_eq!(IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0x1)).is_loopback(), true);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::IpAddr::is_loopback (line 246)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::IpAddr::is_loopback (line 246)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 246,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_724 {
fn main() {
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
assert_eq!(IpAddr::V4(Ipv4Addr::new(224, 254, 0, 0)).is_multicast(), true);
assert_eq!(IpAddr::V6(Ipv6Addr::new(0xff00, 0, 0, 0, 0, 0, 0, 0)).is_multicast(), true);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::IpAddr::is_multicast (line 296)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::IpAddr::is_multicast (line 296)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 296,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_725 {
fn main() {
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
assert_eq!(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)).is_unspecified(), true);
assert_eq!(IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0)).is_unspecified(), true);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::IpAddr::is_unspecified (line 222)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::IpAddr::is_unspecified (line 222)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 222,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_726 {
fn main() {
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
let localhost_v4 = Ipv4Addr::new(127, 0, 0, 1);
assert_eq!(IpAddr::V4(localhost_v4).to_canonical(), localhost_v4);
assert_eq!(IpAddr::V6(localhost_v4.to_ipv6_mapped()).to_canonical(), localhost_v4);
assert_eq!(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)).to_canonical().is_loopback(), true);
assert_eq!(IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0x7f00, 0x1)).is_loopback(), false);
assert_eq!(IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0x7f00, 0x1)).to_canonical().is_loopback(), true);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::IpAddr::to_canonical (line 414)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::IpAddr::to_canonical (line 414)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 414,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_727 {
fn main() {
use std::net::Ipv4Addr;
let localhost = Ipv4Addr::new(127, 0, 0, 1);
assert_eq!("127.0.0.1".parse(), Ok(localhost));
assert_eq!(localhost.is_loopback(), true);
assert!("012.004.002.000".parse::<Ipv4Addr>().is_err()); // all octets are in octal
assert!("0000000.0.0.0".parse::<Ipv4Addr>().is_err()); // first octet is a zero in octal
assert!("0xcb.0x0.0x71.0x00".parse::<Ipv4Addr>().is_err()); // all octets are in hex
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr (line 61)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr (line 61)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 61,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_728 {
fn main() {
use std::net::Ipv4Addr;
assert_eq!(Ipv4Addr::BITS, 32);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::BITS (line 462)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::BITS (line 462)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 462,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_729 {
fn main() {
use std::net::Ipv4Addr;
let addr = Ipv4Addr::BROADCAST;
assert_eq!(addr, Ipv4Addr::new(255, 255, 255, 255));
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::BROADCAST (line 556)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::BROADCAST (line 556)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 556,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_730 {
fn main() {
use std::net::Ipv4Addr;
let addr = Ipv4Addr::LOCALHOST;
assert_eq!(addr, Ipv4Addr::new(127, 0, 0, 1));
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::LOCALHOST (line 527)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::LOCALHOST (line 527)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 527,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_731 {
fn main() {
use std::net::Ipv4Addr;
let addr = Ipv4Addr::UNSPECIFIED;
assert_eq!(addr, Ipv4Addr::new(0, 0, 0, 0));
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::UNSPECIFIED (line 542)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::UNSPECIFIED (line 542)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 542,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_732 {
fn main() {
use std::net::Ipv4Addr;
let addr = Ipv4Addr::from([13u8, 12u8, 11u8, 10u8]);
assert_eq!(Ipv4Addr::new(13, 12, 11, 10), addr);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::from (line 1168)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::from (line 1168)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 1168,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_733 {
fn main() {
use std::net::Ipv4Addr;
let addr = Ipv4Addr::from(0x12345678);
assert_eq!(Ipv4Addr::new(0x12, 0x34, 0x56, 0x78), addr);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::from_bits (line 509)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::from_bits (line 509)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 509,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_734 {
fn main() {
use std::net::Ipv4Addr;
assert_eq!(Ipv4Addr::new(255, 255, 255, 255).is_broadcast(), true);
assert_eq!(Ipv4Addr::new(236, 168, 10, 65).is_broadcast(), false);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::is_broadcast (line 897)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::is_broadcast (line 897)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 897,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_735 {
fn main() {
use std::net::Ipv4Addr;
assert_eq!(Ipv4Addr::new(192, 0, 2, 255).is_documentation(), true);
assert_eq!(Ipv4Addr::new(198, 51, 100, 65).is_documentation(), true);
assert_eq!(Ipv4Addr::new(203, 0, 113, 6).is_documentation(), true);
assert_eq!(Ipv4Addr::new(193, 34, 17, 19).is_documentation(), false);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::is_documentation (line 923)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::is_documentation (line 923)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 923,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_736 {
fn main() {
use std::net::Ipv4Addr;
assert_eq!(Ipv4Addr::new(169, 254, 0, 0).is_link_local(), true);
assert_eq!(Ipv4Addr::new(169, 254, 10, 65).is_link_local(), true);
assert_eq!(Ipv4Addr::new(16, 89, 10, 65).is_link_local(), false);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::is_link_local (line 672)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::is_link_local (line 672)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 672,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_737 {
fn main() {
use std::net::Ipv4Addr;
assert_eq!(Ipv4Addr::new(127, 0, 0, 1).is_loopback(), true);
assert_eq!(Ipv4Addr::new(45, 22, 13, 197).is_loopback(), false);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::is_loopback (line 614)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::is_loopback (line 614)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 614,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_738 {
fn main() {
use std::net::Ipv4Addr;
assert_eq!(Ipv4Addr::new(224, 254, 0, 0).is_multicast(), true);
assert_eq!(Ipv4Addr::new(236, 168, 10, 65).is_multicast(), true);
assert_eq!(Ipv4Addr::new(172, 16, 10, 65).is_multicast(), false);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::is_multicast (line 874)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::is_multicast (line 874)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 874,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_739 {
fn main() {
use std::net::Ipv4Addr;
assert_eq!(Ipv4Addr::new(10, 0, 0, 1).is_private(), true);
assert_eq!(Ipv4Addr::new(10, 10, 10, 10).is_private(), true);
assert_eq!(Ipv4Addr::new(172, 16, 10, 10).is_private(), true);
assert_eq!(Ipv4Addr::new(172, 29, 45, 14).is_private(), true);
assert_eq!(Ipv4Addr::new(172, 32, 0, 2).is_private(), false);
assert_eq!(Ipv4Addr::new(192, 168, 0, 2).is_private(), true);
assert_eq!(Ipv4Addr::new(192, 169, 0, 2).is_private(), false);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::is_private (line 640)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::is_private (line 640)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 640,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_740 {
fn main() {
use std::net::Ipv4Addr;
assert_eq!(Ipv4Addr::new(0, 0, 0, 0).is_unspecified(), true);
assert_eq!(Ipv4Addr::new(45, 22, 13, 197).is_unspecified(), false);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::is_unspecified (line 592)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::is_unspecified (line 592)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 592,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_741 {
fn main() {
use std::net::Ipv4Addr;
let addr = Ipv4Addr::new(127, 0, 0, 1);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::new (line 445)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::new (line 445)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 445,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_742 {
fn main() {
use std::net::Ipv4Addr;
let addr = Ipv4Addr::new(127, 0, 0, 1);
assert_eq!(addr.octets(), [127, 0, 0, 1]);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::octets (line 569)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::octets (line 569)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 569,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_743 {
fn main() {
use std::net::Ipv4Addr;
let addr = Ipv4Addr::new(0x12, 0x34, 0x56, 0x78);
assert_eq!(0x12345678, addr.to_bits());
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::to_bits (line 480)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::to_bits (line 480)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 480,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_744 {
fn main() {
use std::net::Ipv4Addr;
let addr = Ipv4Addr::new(0x12, 0x34, 0x56, 0x78);
let addr_bits = addr.to_bits() & 0xffffff00;
assert_eq!(Ipv4Addr::new(0x12, 0x34, 0x56, 0x00), Ipv4Addr::from_bits(addr_bits));
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::to_bits (line 487)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::to_bits (line 487)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 487,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_745 {
fn main() {
use std::net::{Ipv4Addr, Ipv6Addr};
assert_eq!(
Ipv4Addr::new(192, 0, 2, 255).to_ipv6_compatible(),
Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0xc000, 0x2ff)
);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::to_ipv6_compatible (line 951)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::to_ipv6_compatible (line 951)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 951,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_746 {
fn main() {
use std::net::{Ipv4Addr, Ipv6Addr};
assert_eq!(Ipv4Addr::new(192, 0, 2, 255).to_ipv6_mapped(),
Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc000, 0x2ff));
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::to_ipv6_mapped (line 978)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv4Addr::to_ipv6_mapped (line 978)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 978,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_747 {
fn main() {
use std::net::Ipv6Addr;
let localhost = Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1);
assert_eq!("::1".parse(), Ok(localhost));
assert_eq!(localhost.is_loopback(), true);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr (line 146)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr (line 146)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 146,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_748 {
fn main() {
use std::net::Ipv6Addr;
assert_eq!(Ipv6Addr::BITS, 128);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr::BITS (line 1236)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr::BITS (line 1236)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 1236,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_749 {
fn main() {
use std::net::Ipv6Addr;
let addr = Ipv6Addr::LOCALHOST;
assert_eq!(addr, Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1));
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr::LOCALHOST (line 1320)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr::LOCALHOST (line 1320)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 1320,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_750 {
fn main() {
use std::net::Ipv6Addr;
let addr = Ipv6Addr::UNSPECIFIED;
assert_eq!(addr, Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0));
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr::UNSPECIFIED (line 1337)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr::UNSPECIFIED (line 1337)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 1337,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_751 {
fn main() {
use std::net::Ipv6Addr;
let addr = Ipv6Addr::from([
25u8, 24u8, 23u8, 22u8, 21u8, 20u8, 19u8, 18u8,
17u8, 16u8, 15u8, 14u8, 13u8, 12u8, 11u8, 10u8,
]);
assert_eq!(
Ipv6Addr::new(
0x1918, 0x1716,
0x1514, 0x1312,
0x1110, 0x0f0e,
0x0d0c, 0x0b0a
),
addr
);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr::from (line 2088)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr::from (line 2088)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 2088,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_752 {
fn main() {
use std::net::Ipv6Addr;
let addr = Ipv6Addr::from([
525u16, 524u16, 523u16, 522u16,
521u16, 520u16, 519u16, 518u16,
]);
assert_eq!(
Ipv6Addr::new(
0x20d, 0x20c,
0x20b, 0x20a,
0x209, 0x208,
0x207, 0x206
),
addr
);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr::from (line 2117)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr::from (line 2117)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 2117,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_753 {
fn main() {
use std::net::Ipv6Addr;
let addr = Ipv6Addr::from(0x102030405060708090A0B0C0D0E0F00D_u128);
assert_eq!(
Ipv6Addr::new(
0x1020, 0x3040, 0x5060, 0x7080,
0x90A0, 0xB0C0, 0xD0E0, 0xF00D,
),
addr);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr::from_bits (line 1294)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr::from_bits (line 1294)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 1294,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_754 {
fn main() {
use std::net::Ipv6Addr;
assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).is_loopback(), false);
assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0x1).is_loopback(), true);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr::is_loopback (line 1411)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr::is_loopback (line 1411)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 1411,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_755 {
fn main() {
use std::net::Ipv6Addr;
assert_eq!(Ipv6Addr::new(0xff00, 0, 0, 0, 0, 0, 0, 0).is_multicast(), true);
assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).is_multicast(), false);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr::is_multicast (line 1766)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr::is_multicast (line 1766)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 1766,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_756 {
fn main() {
use std::net::Ipv6Addr;
assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).is_unspecified(), false);
assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0).is_unspecified(), true);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr::is_unspecified (line 1387)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr::is_unspecified (line 1387)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 1387,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_757 {
fn main() {
use std::net::Ipv6Addr;
let addr = Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr::new (line 1205)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr::new (line 1205)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 1205,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_758 {
fn main() {
use std::net::Ipv6Addr;
assert_eq!(Ipv6Addr::new(0xff00, 0, 0, 0, 0, 0, 0, 0).octets(),
[255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr::octets (line 1907)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr::octets (line 1907)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 1907,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_759 {
fn main() {
use std::net::Ipv6Addr;
assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).segments(),
[0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff]);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr::segments (line 1352)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr::segments (line 1352)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 1352,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_760 {
fn main() {
use std::net::Ipv6Addr;
let addr = Ipv6Addr::new(
0x1020, 0x3040, 0x5060, 0x7080,
0x90A0, 0xB0C0, 0xD0E0, 0xF00D,
);
assert_eq!(0x102030405060708090A0B0C0D0E0F00D_u128, u128::from(addr));
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr::to_bits (line 1254)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr::to_bits (line 1254)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 1254,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_761 {
fn main() {
use std::net::Ipv6Addr;
let addr = Ipv6Addr::new(
0x1020, 0x3040, 0x5060, 0x7080,
0x90A0, 0xB0C0, 0xD0E0, 0xF00D,
);
let addr_bits = addr.to_bits() & 0xffffffffffffffffffffffffffff0000_u128;
assert_eq!(
Ipv6Addr::new(
0x1020, 0x3040, 0x5060, 0x7080,
0x90A0, 0xB0C0, 0xD0E0, 0x0000,
),
Ipv6Addr::from_bits(addr_bits));
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr::to_bits (line 1264)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr::to_bits (line 1264)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 1264,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_762 {
fn main() {
use std::net::Ipv6Addr;
assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0x7f00, 0x1).is_loopback(), false);
assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0x7f00, 0x1).to_canonical().is_loopback(), true);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr::to_canonical (line 1887)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr::to_canonical (line 1887)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 1887,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_763 {
fn main() {
use std::net::{Ipv4Addr, Ipv6Addr};
assert_eq!(Ipv6Addr::new(0xff00, 0, 0, 0, 0, 0, 0, 0).to_ipv4(), None);
assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).to_ipv4(),
Some(Ipv4Addr::new(192, 10, 2, 255)));
assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1).to_ipv4(),
Some(Ipv4Addr::new(0, 0, 0, 1)));
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr::to_ipv4 (line 1858)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr::to_ipv4 (line 1858)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 1858,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_764 {
fn main() {
use std::net::{Ipv4Addr, Ipv6Addr};
assert_eq!(Ipv6Addr::new(0xff00, 0, 0, 0, 0, 0, 0, 0).to_ipv4_mapped(), None);
assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).to_ipv4_mapped(),
Some(Ipv4Addr::new(192, 10, 2, 255)));
assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1).to_ipv4_mapped(), None);
}
#[rustc_test_marker = "library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr::to_ipv4_mapped (line 1817)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/ip_addr.rs - net::ip_addr::Ipv6Addr::to_ipv4_mapped (line 1817)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/ip_addr.rs",
start_line: 1817,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_765 {
fn main() {
use std::net::IpAddr;
let _foo: IpAddr = "127.0.0.1:8080".parse().expect("Cannot handle the socket port");
}
#[rustc_test_marker = "library/core/src/net/parser.rs - net::parser::AddrParseError (line 489)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/parser.rs - net::parser::AddrParseError (line 489)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/parser.rs",
start_line: 489,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::Yes,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_766 {
fn main() {
use std::net::SocketAddr;
// No problem, the `panic!` message has disappeared.
let _foo: SocketAddr = "127.0.0.1:8080".parse().expect("unreachable panic");
}
#[rustc_test_marker = "library/core/src/net/parser.rs - net::parser::AddrParseError (line 496)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/parser.rs - net::parser::AddrParseError (line 496)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/parser.rs",
start_line: 496,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_767 {
fn main() {
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
let socket = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080);
assert_eq!("127.0.0.1:8080".parse(), Ok(socket));
assert_eq!(socket.port(), 8080);
assert_eq!(socket.is_ipv4(), true);
}
#[rustc_test_marker = "library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddr (line 19)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddr (line 19)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/socket_addr.rs",
start_line: 19,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_768 {
fn main() {
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
let socket = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080);
assert_eq!(socket.ip(), IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)));
}
#[rustc_test_marker = "library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddr::ip (line 135)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddr::ip (line 135)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/socket_addr.rs",
start_line: 135,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_769 {
fn main() {
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
let socket = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080);
assert_eq!(socket.is_ipv4(), true);
assert_eq!(socket.is_ipv6(), false);
}
#[rustc_test_marker = "library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddr::is_ipv4 (line 223)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddr::is_ipv4 (line 223)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/socket_addr.rs",
start_line: 223,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_770 {
fn main() {
use std::net::{IpAddr, Ipv6Addr, SocketAddr};
let socket = SocketAddr::new(IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 65535, 0, 1)), 8080);
assert_eq!(socket.is_ipv4(), false);
assert_eq!(socket.is_ipv6(), true);
}
#[rustc_test_marker = "library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddr::is_ipv6 (line 246)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddr::is_ipv6 (line 246)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/socket_addr.rs",
start_line: 246,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_771 {
fn main() {
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
let socket = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080);
assert_eq!(socket.ip(), IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)));
assert_eq!(socket.port(), 8080);
}
#[rustc_test_marker = "library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddr::new (line 113)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddr::new (line 113)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/socket_addr.rs",
start_line: 113,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_772 {
fn main() {
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
let socket = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080);
assert_eq!(socket.port(), 8080);
}
#[rustc_test_marker = "library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddr::port (line 178)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddr::port (line 178)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/socket_addr.rs",
start_line: 178,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_773 {
fn main() {
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
let mut socket = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080);
socket.set_ip(IpAddr::V4(Ipv4Addr::new(10, 10, 0, 1)));
assert_eq!(socket.ip(), IpAddr::V4(Ipv4Addr::new(10, 10, 0, 1)));
}
#[rustc_test_marker = "library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddr::set_ip (line 156)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddr::set_ip (line 156)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/socket_addr.rs",
start_line: 156,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_774 {
fn main() {
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
let mut socket = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080);
socket.set_port(1025);
assert_eq!(socket.port(), 1025);
}
#[rustc_test_marker = "library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddr::set_port (line 199)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddr::set_port (line 199)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/socket_addr.rs",
start_line: 199,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_775 {
fn main() {
use std::net::{Ipv4Addr, SocketAddrV4};
let socket = SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), 8080);
assert_eq!("127.0.0.1:8080".parse(), Ok(socket));
assert_eq!(socket.ip(), &Ipv4Addr::new(127, 0, 0, 1));
assert_eq!(socket.port(), 8080);
}
#[rustc_test_marker = "library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddrV4 (line 55)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddrV4 (line 55)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/socket_addr.rs",
start_line: 55,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_776 {
fn main() {
use std::net::{SocketAddrV4, Ipv4Addr};
let socket = SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), 8080);
assert_eq!(socket.ip(), &Ipv4Addr::new(127, 0, 0, 1));
}
#[rustc_test_marker = "library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddrV4::ip (line 286)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddrV4::ip (line 286)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/socket_addr.rs",
start_line: 286,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_777 {
fn main() {
use std::net::{SocketAddrV4, Ipv4Addr};
let socket = SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), 8080);
}
#[rustc_test_marker = "library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddrV4::new (line 269)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddrV4::new (line 269)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/socket_addr.rs",
start_line: 269,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_778 {
fn main() {
use std::net::{SocketAddrV4, Ipv4Addr};
let socket = SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), 8080);
assert_eq!(socket.port(), 8080);
}
#[rustc_test_marker = "library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddrV4::port (line 321)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddrV4::port (line 321)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/socket_addr.rs",
start_line: 321,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_779 {
fn main() {
use std::net::{SocketAddrV4, Ipv4Addr};
let mut socket = SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), 8080);
socket.set_ip(Ipv4Addr::new(192, 168, 0, 1));
assert_eq!(socket.ip(), &Ipv4Addr::new(192, 168, 0, 1));
}
#[rustc_test_marker = "library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddrV4::set_ip (line 304)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddrV4::set_ip (line 304)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/socket_addr.rs",
start_line: 304,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_780 {
fn main() {
use std::net::{SocketAddrV4, Ipv4Addr};
let mut socket = SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), 8080);
socket.set_port(4242);
assert_eq!(socket.port(), 4242);
}
#[rustc_test_marker = "library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddrV4::set_port (line 339)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddrV4::set_port (line 339)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/socket_addr.rs",
start_line: 339,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_781 {
fn main() {
use std::net::{Ipv6Addr, SocketAddrV6};
let socket = SocketAddrV6::new(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 1), 8080, 0, 0);
assert_eq!("[2001:db8::1]:8080".parse(), Ok(socket));
assert_eq!(socket.ip(), &Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 1));
assert_eq!(socket.port(), 8080);
}
#[rustc_test_marker = "library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddrV6 (line 88)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddrV6 (line 88)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/socket_addr.rs",
start_line: 88,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_782 {
fn main() {
use std::net::{SocketAddrV6, Ipv6Addr};
let socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 10, 0);
assert_eq!(socket.flowinfo(), 10);
}
#[rustc_test_marker = "library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddrV6::flowinfo (line 462)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddrV6::flowinfo (line 462)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/socket_addr.rs",
start_line: 462,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_783 {
fn main() {
use std::net::{SocketAddrV6, Ipv6Addr};
let socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 0, 0);
assert_eq!(socket.ip(), &Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1));
}
#[rustc_test_marker = "library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddrV6::ip (line 382)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddrV6::ip (line 382)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/socket_addr.rs",
start_line: 382,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_784 {
fn main() {
use std::net::{SocketAddrV6, Ipv6Addr};
let socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 0, 0);
}
#[rustc_test_marker = "library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddrV6::new (line 365)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddrV6::new (line 365)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/socket_addr.rs",
start_line: 365,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_785 {
fn main() {
use std::net::{SocketAddrV6, Ipv6Addr};
let socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 0, 0);
assert_eq!(socket.port(), 8080);
}
#[rustc_test_marker = "library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddrV6::port (line 417)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddrV6::port (line 417)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/socket_addr.rs",
start_line: 417,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_786 {
fn main() {
use std::net::{SocketAddrV6, Ipv6Addr};
let socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 0, 78);
assert_eq!(socket.scope_id(), 78);
}
#[rustc_test_marker = "library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddrV6::scope_id (line 504)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddrV6::scope_id (line 504)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/socket_addr.rs",
start_line: 504,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_787 {
fn main() {
use std::net::{SocketAddrV6, Ipv6Addr};
let mut socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 10, 0);
socket.set_flowinfo(56);
assert_eq!(socket.flowinfo(), 56);
}
#[rustc_test_marker = "library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddrV6::set_flowinfo (line 482)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddrV6::set_flowinfo (line 482)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/socket_addr.rs",
start_line: 482,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_788 {
fn main() {
use std::net::{SocketAddrV6, Ipv6Addr};
let mut socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 0, 0);
socket.set_ip(Ipv6Addr::new(76, 45, 0, 0, 0, 0, 0, 0));
assert_eq!(socket.ip(), &Ipv6Addr::new(76, 45, 0, 0, 0, 0, 0, 0));
}
#[rustc_test_marker = "library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddrV6::set_ip (line 400)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddrV6::set_ip (line 400)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/socket_addr.rs",
start_line: 400,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_789 {
fn main() {
use std::net::{SocketAddrV6, Ipv6Addr};
let mut socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 0, 0);
socket.set_port(4242);
assert_eq!(socket.port(), 4242);
}
#[rustc_test_marker = "library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddrV6::set_port (line 435)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddrV6::set_port (line 435)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/socket_addr.rs",
start_line: 435,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_790 {
fn main() {
use std::net::{SocketAddrV6, Ipv6Addr};
let mut socket = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8080, 0, 78);
socket.set_scope_id(42);
assert_eq!(socket.scope_id(), 42);
}
#[rustc_test_marker = "library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddrV6::set_scope_id (line 524)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/net/socket_addr.rs - net::socket_addr::SocketAddrV6::set_scope_id (line 524)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/net/socket_addr.rs",
start_line: 524,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_791 {
fn main() {
use std::str::FromStr;
if let Err(e) = f64::from_str("a.12") {
println!("Failed conversion to f64: {e}");
}
}
#[rustc_test_marker = "library/core/src/num/dec2flt/mod.rs - num::dec2flt::ParseFloatError (line 173)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/dec2flt/mod.rs - num::dec2flt::ParseFloatError (line 173)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/dec2flt/mod.rs",
start_line: 173,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_792 {
fn main() {
if let Err(e) = i32::from_str_radix("a12", 10) {
println!("Failed conversion to i32: {:?}", e.kind());
}
}
#[rustc_test_marker = "library/core/src/num/error.rs - num::error::IntErrorKind (line 74)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/error.rs - num::error::IntErrorKind (line 74)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/error.rs",
start_line: 74,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_793 {
fn main() {
if let Err(e) = i32::from_str_radix("a12", 10) {
println!("Failed conversion to i32: {e}");
}
}
#[rustc_test_marker = "library/core/src/num/error.rs - num::error::ParseIntError (line 59)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/error.rs - num::error::ParseIntError (line 59)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/error.rs",
start_line: 59,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_794 {
fn main() {
#[allow(deprecated, deprecated_in_future)]
let d = std::f32::DIGITS;
// intended way
let d = f32::DIGITS;
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::DIGITS (line 64)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::DIGITS (line 64)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 64,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_795 {
fn main() {
#[allow(deprecated, deprecated_in_future)]
let e = std::f32::EPSILON;
// intended way
let e = f32::EPSILON;
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::EPSILON (line 86)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::EPSILON (line 86)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 86,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_796 {
fn main() {
#[allow(deprecated, deprecated_in_future)]
let inf = std::f32::INFINITY;
// intended way
let inf = f32::INFINITY;
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::INFINITY (line 248)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::INFINITY (line 248)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 248,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_797 {
fn main() {
#[allow(deprecated, deprecated_in_future)]
let d = std::f32::MANTISSA_DIGITS;
// intended way
let d = f32::MANTISSA_DIGITS;
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::MANTISSA_DIGITS (line 43)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::MANTISSA_DIGITS (line 43)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 43,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_798 {
fn main() {
#[allow(deprecated, deprecated_in_future)]
let max = std::f32::MAX;
// intended way
let max = f32::MAX;
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::MAX (line 140)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::MAX (line 140)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 140,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_799 {
fn main() {
#[allow(deprecated, deprecated_in_future)]
let max = std::f32::MAX_10_EXP;
// intended way
let max = f32::MAX_10_EXP;
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::MAX_10_EXP (line 212)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::MAX_10_EXP (line 212)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 212,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_800 {
fn main() {
#[allow(deprecated, deprecated_in_future)]
let max = std::f32::MAX_EXP;
// intended way
let max = f32::MAX_EXP;
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::MAX_EXP (line 176)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::MAX_EXP (line 176)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 176,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_801 {
fn main() {
#[allow(deprecated, deprecated_in_future)]
let min = std::f32::MIN;
// intended way
let min = f32::MIN;
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::MIN (line 104)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::MIN (line 104)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 104,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_802 {
fn main() {
#[allow(deprecated, deprecated_in_future)]
let min = std::f32::MIN_10_EXP;
// intended way
let min = f32::MIN_10_EXP;
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::MIN_10_EXP (line 194)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::MIN_10_EXP (line 194)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 194,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_803 {
fn main() {
#[allow(deprecated, deprecated_in_future)]
let min = std::f32::MIN_EXP;
// intended way
let min = f32::MIN_EXP;
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::MIN_EXP (line 158)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::MIN_EXP (line 158)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 158,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_804 {
fn main() {
#[allow(deprecated, deprecated_in_future)]
let min = std::f32::MIN_POSITIVE;
// intended way
let min = f32::MIN_POSITIVE;
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::MIN_POSITIVE (line 122)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::MIN_POSITIVE (line 122)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 122,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_805 {
fn main() {
#[allow(deprecated, deprecated_in_future)]
let nan = std::f32::NAN;
// intended way
let nan = f32::NAN;
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::NAN (line 230)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::NAN (line 230)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 230,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_806 {
fn main() {
#[allow(deprecated, deprecated_in_future)]
let ninf = std::f32::NEG_INFINITY;
// intended way
let ninf = f32::NEG_INFINITY;
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::NEG_INFINITY (line 266)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::NEG_INFINITY (line 266)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 266,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_807 {
fn main() {
#[allow(deprecated, deprecated_in_future)]
let r = std::f32::RADIX;
// intended way
let r = f32::RADIX;
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::RADIX (line 25)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::RADIX (line 25)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 25,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_808 {
fn main() {
assert!((-3.0f32).clamp(-2.0, 1.0) == -2.0);
assert!((0.0f32).clamp(-2.0, 1.0) == 0.0);
assert!((2.0f32).clamp(-2.0, 1.0) == 1.0);
assert!((f32::NAN).clamp(-2.0, 1.0).is_nan());
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::f32::clamp (line 1524)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::f32::clamp (line 1524)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 1524,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_809 {
fn main() {
use std::num::FpCategory;
let num = 12.4_f32;
let inf = f32::INFINITY;
assert_eq!(num.classify(), FpCategory::Normal);
assert_eq!(inf.classify(), FpCategory::Infinite);
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::f32::classify (line 628)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::f32::classify (line 628)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 628,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_810 {
fn main() {
let value = f32::from_be_bytes([0x41, 0x48, 0x00, 0x00]);
assert_eq!(value, 12.5);
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::f32::from_be_bytes (line 1355)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::f32::from_be_bytes (line 1355)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 1355,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_811 {
fn main() {
let v = f32::from_bits(0x41480000);
assert_eq!(v, 12.5);
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::f32::from_bits (line 1213)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::f32::from_bits (line 1213)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 1213,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_812 {
fn main() {
let value = f32::from_le_bytes([0x00, 0x00, 0x48, 0x41]);
assert_eq!(value, 12.5);
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::f32::from_le_bytes (line 1374)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::f32::from_le_bytes (line 1374)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 1374,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_813 {
fn main() {
let value = f32::from_ne_bytes(if cfg!(target_endian = "big") {
[0x41, 0x48, 0x00, 0x00]
} else {
[0x00, 0x00, 0x48, 0x41]
});
assert_eq!(value, 12.5);
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::f32::from_ne_bytes (line 1400)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::f32::from_ne_bytes (line 1400)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 1400,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_814 {
fn main() {
let f = 7.0f32;
let inf = f32::INFINITY;
let neg_inf = f32::NEG_INFINITY;
let nan = f32::NAN;
assert!(f.is_finite());
assert!(!nan.is_finite());
assert!(!inf.is_finite());
assert!(!neg_inf.is_finite());
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::f32::is_finite (line 549)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::f32::is_finite (line 549)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 549,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_815 {
fn main() {
let f = 7.0f32;
let inf = f32::INFINITY;
let neg_inf = f32::NEG_INFINITY;
let nan = f32::NAN;
assert!(!f.is_infinite());
assert!(!nan.is_infinite());
assert!(inf.is_infinite());
assert!(neg_inf.is_infinite());
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::f32::is_infinite (line 524)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::f32::is_infinite (line 524)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 524,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_816 {
fn main() {
let nan = f32::NAN;
let f = 7.0_f32;
assert!(nan.is_nan());
assert!(!f.is_nan());
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::f32::is_nan (line 495)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::f32::is_nan (line 495)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 495,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_817 {
fn main() {
let min = f32::MIN_POSITIVE; // 1.17549435e-38f32
let max = f32::MAX;
let lower_than_min = 1.0e-40_f32;
let zero = 0.0_f32;
assert!(min.is_normal());
assert!(max.is_normal());
assert!(!zero.is_normal());
assert!(!f32::NAN.is_normal());
assert!(!f32::INFINITY.is_normal());
// Values between `0` and `min` are Subnormal.
assert!(!lower_than_min.is_normal());
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::f32::is_normal (line 600)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::f32::is_normal (line 600)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 600,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_818 {
fn main() {
let f = 7.0f32;
let g = -7.0f32;
assert!(!f.is_sign_negative());
assert!(g.is_sign_negative());
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::f32::is_sign_negative (line 743)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::f32::is_sign_negative (line 743)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 743,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_819 {
fn main() {
let f = 7.0_f32;
let g = -7.0_f32;
assert!(f.is_sign_positive());
assert!(!g.is_sign_positive());
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::f32::is_sign_positive (line 721)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::f32::is_sign_positive (line 721)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 721,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_820 {
fn main() {
let min = f32::MIN_POSITIVE; // 1.17549435e-38f32
let max = f32::MAX;
let lower_than_min = 1.0e-40_f32;
let zero = 0.0_f32;
assert!(!min.is_subnormal());
assert!(!max.is_subnormal());
assert!(!zero.is_subnormal());
assert!(!f32::NAN.is_subnormal());
assert!(!f32::INFINITY.is_subnormal());
// Values between `0` and `min` are Subnormal.
assert!(lower_than_min.is_subnormal());
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::f32::is_subnormal (line 573)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::f32::is_subnormal (line 573)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 573,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_821 {
fn main() {
let x = 1.0f32;
let y = 2.0f32;
assert_eq!(x.max(y), y);
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::f32::max (line 920)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::f32::max (line 920)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 920,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_822 {
fn main() {
let x = 1.0f32;
let y = 2.0f32;
assert_eq!(x.min(y), x);
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::f32::min (line 940)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::f32::min (line 940)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 940,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_823 {
fn main() {
let x = 2.0_f32;
let abs_difference = (x.recip() - (1.0 / x)).abs();
assert!(abs_difference <= f32::EPSILON);
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::f32::recip (line 863)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::f32::recip (line 863)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 863,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_824 {
fn main() {
let bytes = 12.5f32.to_be_bytes();
assert_eq!(bytes, [0x41, 0x48, 0x00, 0x00]);
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::f32::to_be_bytes (line 1280)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::f32::to_be_bytes (line 1280)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 1280,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_825 {
fn main() {
assert_ne!((1f32).to_bits(), 1f32 as u32); // to_bits() is not casting!
assert_eq!((12.5f32).to_bits(), 0x41480000);
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::f32::to_bits (line 1122)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::f32::to_bits (line 1122)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 1122,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_826 {
fn main() {
let angle = std::f32::consts::PI;
let abs_difference = (angle.to_degrees() - 180.0).abs();
#[cfg(any(not(target_arch = "x86"), target_feature = "sse2"))]
assert!(abs_difference <= f32::EPSILON);
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::f32::to_degrees (line 878)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::f32::to_degrees (line 878)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 878,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_827 {
fn main() {
let value = 4.6_f32;
let rounded = unsafe { value.to_int_unchecked::<u16>() };
assert_eq!(rounded, 4);
let value = -128.9_f32;
let rounded = unsafe { value.to_int_unchecked::<i8>() };
assert_eq!(rounded, i8::MIN);
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::f32::to_int_unchecked (line 1080)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::f32::to_int_unchecked (line 1080)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 1080,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_828 {
fn main() {
let bytes = 12.5f32.to_le_bytes();
assert_eq!(bytes, [0x00, 0x00, 0x48, 0x41]);
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::f32::to_le_bytes (line 1301)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::f32::to_le_bytes (line 1301)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 1301,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_829 {
fn main() {
let bytes = 12.5f32.to_ne_bytes();
assert_eq!(
bytes,
if cfg!(target_endian = "big") {
[0x41, 0x48, 0x00, 0x00]
} else {
[0x00, 0x00, 0x48, 0x41]
}
);
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::f32::to_ne_bytes (line 1328)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::f32::to_ne_bytes (line 1328)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 1328,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_830 {
fn main() {
let angle = 180.0f32;
let abs_difference = (angle.to_radians() - std::f32::consts::PI).abs();
assert!(abs_difference <= f32::EPSILON);
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::f32::to_radians (line 897)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::f32::to_radians (line 897)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 897,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_831 {
fn main() {
struct GoodBoy {
name: String,
weight: f32,
}
let mut bois = vec![
GoodBoy { name: "Pucci".to_owned(), weight: 0.1 },
GoodBoy { name: "Woofer".to_owned(), weight: 99.0 },
GoodBoy { name: "Yapper".to_owned(), weight: 10.0 },
GoodBoy { name: "Chonk".to_owned(), weight: f32::INFINITY },
GoodBoy { name: "Abs. Unit".to_owned(), weight: f32::NAN },
GoodBoy { name: "Floaty".to_owned(), weight: -5.0 },
];
bois.sort_by(|a, b| a.weight.total_cmp(&b.weight));
// `f32::NAN` could be positive or negative, which will affect the sort order.
if f32::NAN.is_sign_negative() {
assert!(bois.into_iter().map(|b| b.weight)
.zip([f32::NAN, -5.0, 0.1, 10.0, 99.0, f32::INFINITY].iter())
.all(|(a, b)| a.to_bits() == b.to_bits()))
} else {
assert!(bois.into_iter().map(|b| b.weight)
.zip([-5.0, 0.1, 10.0, 99.0, f32::INFINITY, f32::NAN].iter())
.all(|(a, b)| a.to_bits() == b.to_bits()))
}
}
#[rustc_test_marker = "library/core/src/num/f32.rs - f32::f32::total_cmp (line 1447)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f32.rs - f32::f32::total_cmp (line 1447)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f32.rs",
start_line: 1447,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_832 {
fn main() {
#[allow(deprecated, deprecated_in_future)]
let d = std::f64::DIGITS;
// intended way
let d = f64::DIGITS;
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::DIGITS (line 64)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::DIGITS (line 64)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 64,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_833 {
fn main() {
#[allow(deprecated, deprecated_in_future)]
let e = std::f64::EPSILON;
// intended way
let e = f64::EPSILON;
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::EPSILON (line 86)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::EPSILON (line 86)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 86,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_834 {
fn main() {
#[allow(deprecated, deprecated_in_future)]
let inf = std::f64::INFINITY;
// intended way
let inf = f64::INFINITY;
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::INFINITY (line 248)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::INFINITY (line 248)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 248,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_835 {
fn main() {
#[allow(deprecated, deprecated_in_future)]
let d = std::f64::MANTISSA_DIGITS;
// intended way
let d = f64::MANTISSA_DIGITS;
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::MANTISSA_DIGITS (line 43)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::MANTISSA_DIGITS (line 43)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 43,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_836 {
fn main() {
#[allow(deprecated, deprecated_in_future)]
let max = std::f64::MAX;
// intended way
let max = f64::MAX;
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::MAX (line 140)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::MAX (line 140)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 140,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_837 {
fn main() {
#[allow(deprecated, deprecated_in_future)]
let max = std::f64::MAX_10_EXP;
// intended way
let max = f64::MAX_10_EXP;
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::MAX_10_EXP (line 212)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::MAX_10_EXP (line 212)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 212,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_838 {
fn main() {
#[allow(deprecated, deprecated_in_future)]
let max = std::f64::MAX_EXP;
// intended way
let max = f64::MAX_EXP;
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::MAX_EXP (line 176)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::MAX_EXP (line 176)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 176,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_839 {
fn main() {
#[allow(deprecated, deprecated_in_future)]
let min = std::f64::MIN;
// intended way
let min = f64::MIN;
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::MIN (line 104)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::MIN (line 104)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 104,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_840 {
fn main() {
#[allow(deprecated, deprecated_in_future)]
let min = std::f64::MIN_10_EXP;
// intended way
let min = f64::MIN_10_EXP;
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::MIN_10_EXP (line 194)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::MIN_10_EXP (line 194)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 194,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_841 {
fn main() {
#[allow(deprecated, deprecated_in_future)]
let min = std::f64::MIN_EXP;
// intended way
let min = f64::MIN_EXP;
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::MIN_EXP (line 158)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::MIN_EXP (line 158)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 158,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_842 {
fn main() {
#[allow(deprecated, deprecated_in_future)]
let min = std::f64::MIN_POSITIVE;
// intended way
let min = f64::MIN_POSITIVE;
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::MIN_POSITIVE (line 122)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::MIN_POSITIVE (line 122)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 122,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_843 {
fn main() {
#[allow(deprecated, deprecated_in_future)]
let nan = std::f64::NAN;
// intended way
let nan = f64::NAN;
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::NAN (line 230)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::NAN (line 230)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 230,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_844 {
fn main() {
#[allow(deprecated, deprecated_in_future)]
let ninf = std::f64::NEG_INFINITY;
// intended way
let ninf = f64::NEG_INFINITY;
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::NEG_INFINITY (line 266)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::NEG_INFINITY (line 266)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 266,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_845 {
fn main() {
#[allow(deprecated, deprecated_in_future)]
let r = std::f64::RADIX;
// intended way
let r = f64::RADIX;
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::RADIX (line 25)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::RADIX (line 25)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 25,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_846 {
fn main() {
assert!((-3.0f64).clamp(-2.0, 1.0) == -2.0);
assert!((0.0f64).clamp(-2.0, 1.0) == 0.0);
assert!((2.0f64).clamp(-2.0, 1.0) == 1.0);
assert!((f64::NAN).clamp(-2.0, 1.0).is_nan());
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::f64::clamp (line 1504)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::f64::clamp (line 1504)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 1504,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_847 {
fn main() {
use std::num::FpCategory;
let num = 12.4_f64;
let inf = f64::INFINITY;
assert_eq!(num.classify(), FpCategory::Normal);
assert_eq!(inf.classify(), FpCategory::Infinite);
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::f64::classify (line 629)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::f64::classify (line 629)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 629,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_848 {
fn main() {
let value = f64::from_be_bytes([0x40, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
assert_eq!(value, 12.5);
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::f64::from_be_bytes (line 1335)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::f64::from_be_bytes (line 1335)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 1335,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_849 {
fn main() {
let v = f64::from_bits(0x4029000000000000);
assert_eq!(v, 12.5);
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::f64::from_bits (line 1188)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::f64::from_bits (line 1188)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 1188,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_850 {
fn main() {
let value = f64::from_le_bytes([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x29, 0x40]);
assert_eq!(value, 12.5);
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::f64::from_le_bytes (line 1354)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::f64::from_le_bytes (line 1354)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 1354,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_851 {
fn main() {
let value = f64::from_ne_bytes(if cfg!(target_endian = "big") {
[0x40, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
} else {
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x29, 0x40]
});
assert_eq!(value, 12.5);
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::f64::from_ne_bytes (line 1380)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::f64::from_ne_bytes (line 1380)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 1380,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_852 {
fn main() {
let f = 7.0f64;
let inf: f64 = f64::INFINITY;
let neg_inf: f64 = f64::NEG_INFINITY;
let nan: f64 = f64::NAN;
assert!(f.is_finite());
assert!(!nan.is_finite());
assert!(!inf.is_finite());
assert!(!neg_inf.is_finite());
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::f64::is_finite (line 550)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::f64::is_finite (line 550)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 550,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_853 {
fn main() {
let f = 7.0f64;
let inf = f64::INFINITY;
let neg_inf = f64::NEG_INFINITY;
let nan = f64::NAN;
assert!(!f.is_infinite());
assert!(!nan.is_infinite());
assert!(inf.is_infinite());
assert!(neg_inf.is_infinite());
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::f64::is_infinite (line 525)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::f64::is_infinite (line 525)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 525,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_854 {
fn main() {
let nan = f64::NAN;
let f = 7.0_f64;
assert!(nan.is_nan());
assert!(!f.is_nan());
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::f64::is_nan (line 494)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::f64::is_nan (line 494)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 494,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_855 {
fn main() {
let min = f64::MIN_POSITIVE; // 2.2250738585072014e-308f64
let max = f64::MAX;
let lower_than_min = 1.0e-308_f64;
let zero = 0.0f64;
assert!(min.is_normal());
assert!(max.is_normal());
assert!(!zero.is_normal());
assert!(!f64::NAN.is_normal());
assert!(!f64::INFINITY.is_normal());
// Values between `0` and `min` are Subnormal.
assert!(!lower_than_min.is_normal());
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::f64::is_normal (line 601)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::f64::is_normal (line 601)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 601,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_856 {
fn main() {
let f = 7.0_f64;
let g = -7.0_f64;
assert!(!f.is_sign_negative());
assert!(g.is_sign_negative());
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::f64::is_sign_negative (line 744)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::f64::is_sign_negative (line 744)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 744,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_857 {
fn main() {
let f = 7.0_f64;
let g = -7.0_f64;
assert!(f.is_sign_positive());
assert!(!g.is_sign_positive());
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::f64::is_sign_positive (line 713)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::f64::is_sign_positive (line 713)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 713,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_858 {
fn main() {
let min = f64::MIN_POSITIVE; // 2.2250738585072014e-308_f64
let max = f64::MAX;
let lower_than_min = 1.0e-308_f64;
let zero = 0.0_f64;
assert!(!min.is_subnormal());
assert!(!max.is_subnormal());
assert!(!zero.is_subnormal());
assert!(!f64::NAN.is_subnormal());
assert!(!f64::INFINITY.is_subnormal());
// Values between `0` and `min` are Subnormal.
assert!(lower_than_min.is_subnormal());
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::f64::is_subnormal (line 574)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::f64::is_subnormal (line 574)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 574,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_859 {
fn main() {
let x = 1.0_f64;
let y = 2.0_f64;
assert_eq!(x.max(y), y);
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::f64::max (line 931)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::f64::max (line 931)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 931,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_860 {
fn main() {
let x = 1.0_f64;
let y = 2.0_f64;
assert_eq!(x.min(y), x);
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::f64::min (line 951)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::f64::min (line 951)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 951,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_861 {
fn main() {
let x = 2.0_f64;
let abs_difference = (x.recip() - (1.0 / x)).abs();
assert!(abs_difference < 1e-10);
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::f64::recip (line 873)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::f64::recip (line 873)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 873,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_862 {
fn main() {
let bytes = 12.5f64.to_be_bytes();
assert_eq!(bytes, [0x40, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::f64::to_be_bytes (line 1260)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::f64::to_be_bytes (line 1260)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 1260,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_863 {
fn main() {
assert!((1f64).to_bits() != 1f64 as u64); // to_bits() is not casting!
assert_eq!((12.5f64).to_bits(), 0x4029000000000000);
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::f64::to_bits (line 1116)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::f64::to_bits (line 1116)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 1116,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_864 {
fn main() {
let angle = std::f64::consts::PI;
let abs_difference = (angle.to_degrees() - 180.0).abs();
assert!(abs_difference < 1e-10);
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::f64::to_degrees (line 888)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::f64::to_degrees (line 888)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 888,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_865 {
fn main() {
let value = 4.6_f64;
let rounded = unsafe { value.to_int_unchecked::<u16>() };
assert_eq!(rounded, 4);
let value = -128.9_f64;
let rounded = unsafe { value.to_int_unchecked::<i8>() };
assert_eq!(rounded, i8::MIN);
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::f64::to_int_unchecked (line 1074)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::f64::to_int_unchecked (line 1074)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 1074,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_866 {
fn main() {
let bytes = 12.5f64.to_le_bytes();
assert_eq!(bytes, [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x29, 0x40]);
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::f64::to_le_bytes (line 1281)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::f64::to_le_bytes (line 1281)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 1281,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_867 {
fn main() {
let bytes = 12.5f64.to_ne_bytes();
assert_eq!(
bytes,
if cfg!(target_endian = "big") {
[0x40, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
} else {
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x29, 0x40]
}
);
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::f64::to_ne_bytes (line 1308)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::f64::to_ne_bytes (line 1308)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 1308,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_868 {
fn main() {
let angle = 180.0_f64;
let abs_difference = (angle.to_radians() - std::f64::consts::PI).abs();
assert!(abs_difference < 1e-10);
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::f64::to_radians (line 908)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::f64::to_radians (line 908)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 908,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_869 {
fn main() {
struct GoodBoy {
name: String,
weight: f64,
}
let mut bois = vec![
GoodBoy { name: "Pucci".to_owned(), weight: 0.1 },
GoodBoy { name: "Woofer".to_owned(), weight: 99.0 },
GoodBoy { name: "Yapper".to_owned(), weight: 10.0 },
GoodBoy { name: "Chonk".to_owned(), weight: f64::INFINITY },
GoodBoy { name: "Abs. Unit".to_owned(), weight: f64::NAN },
GoodBoy { name: "Floaty".to_owned(), weight: -5.0 },
];
bois.sort_by(|a, b| a.weight.total_cmp(&b.weight));
// `f64::NAN` could be positive or negative, which will affect the sort order.
if f64::NAN.is_sign_negative() {
assert!(bois.into_iter().map(|b| b.weight)
.zip([f64::NAN, -5.0, 0.1, 10.0, 99.0, f64::INFINITY].iter())
.all(|(a, b)| a.to_bits() == b.to_bits()))
} else {
assert!(bois.into_iter().map(|b| b.weight)
.zip([-5.0, 0.1, 10.0, 99.0, f64::INFINITY, f64::NAN].iter())
.all(|(a, b)| a.to_bits() == b.to_bits()))
}
}
#[rustc_test_marker = "library/core/src/num/f64.rs - f64::f64::total_cmp (line 1427)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/f64.rs - f64::f64::total_cmp (line 1427)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/f64.rs",
start_line: 1427,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_870 {
fn main() {
use std::num::FpCategory;
let num = 12.4_f32;
let inf = f32::INFINITY;
let zero = 0f32;
let sub: f32 = 1.1754942e-38;
let nan = f32::NAN;
assert_eq!(num.classify(), FpCategory::Normal);
assert_eq!(inf.classify(), FpCategory::Infinite);
assert_eq!(zero.classify(), FpCategory::Zero);
assert_eq!(sub.classify(), FpCategory::Subnormal);
assert_eq!(nan.classify(), FpCategory::Nan);
}
#[rustc_test_marker = "library/core/src/num/mod.rs - num::FpCategory (line 1321)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/mod.rs - num::FpCategory (line 1321)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/mod.rs",
start_line: 1321,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: false,
should_panic: test::ShouldPanic::No,
test_type: test::TestType::UnitTest,
},
testfn: test::StaticTestFn(
#[coverage(off)]
|| test::assert_test_result(self::main()),
)
};
}
mod __doctest_871 {
fn main() {
assert_eq!(i128::BITS, 128);
}
#[rustc_test_marker = "library/core/src/num/mod.rs - num::i128::BITS (line 386)"]
pub const TEST: test::TestDescAndFn = test::TestDescAndFn {
desc: test::TestDesc {
name: test::StaticTestName("library/core/src/num/mod.rs - num::i128::BITS (line 386)"),
ignore: false,
ignore_message: None,
source_file: "library/core/src/num/mod.rs",
start_line: 386,
start_col: 0,
end_line: 0,
end_col: 0,
compile_fail: false,
no_run: fa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment