profile = "library"[llvm]download-ci-llvm = true[rust]# Download pre-built compiler if working only on librarydownload-rustc = "if-unchanged"# Build library with debug infodebuginfo-level-std = 1
2
Build the library
# Build just the standard library./x.py build library/std# Build core library./x.py build library/core# Build alloc library./x.py build library/alloc
3
Test your changes
# Test standard library./x.py test library/std# Test core library./x.py test library/core# Test specific module./x.py test library/std --test-args vec
// library/core/src/slice/mod.rsimpl<T> [T] { /// Returns the first element of the slice. #[stable(feature = "slice_first", since = "1.0.0")] pub const fn first(&self) -> Option<&T> { if let [first, ..] = self { Some(first) } else { None } }}
// library/core/src/ptr/mod.rs/// Reads the value from `src` without moving it.#[inline]#[stable(feature = "rust1", since = "1.0.0")]pub const unsafe fn read<T>(src: *const T) -> T { // SAFETY: the caller must guarantee that `src` is valid unsafe { let mut tmp = MaybeUninit::<T>::uninit(); copy_nonoverlapping(src, tmp.as_mut_ptr(), 1); tmp.assume_init() }}
// library/core/tests/slice.rs#[test]fn test_first() { let v: &[i32] = &[1, 2, 3]; assert_eq!(v.first(), Some(&1)); let empty: &[i32] = &[]; assert_eq!(empty.first(), None);}
Edit the appropriate library file in library/core/, library/alloc/, or library/std/.
2
Add tests
Doc Tests
Unit Tests
/// Returns the first element.////// # Examples////// ```/// let v = vec![1, 2, 3];/// assert_eq!(v.first(), Some(&1));/// ```pub fn first(&self) -> Option<&T> { // implementation}
// In library/core/tests/ or library/std/tests/#[test]fn test_vec_push() { let mut v = Vec::new(); v.push(1); v.push(2); assert_eq!(v, [1, 2]);}
3
Build and test
# Build the library./x.py build library/std# Run library tests./x.py test library/std# Run doc tests./x.py test library/std --doc# Test specific module./x.py test library/std --test-args vec
4
Check all platforms
# Test on different platforms./x.py test library/std --target x86_64-pc-windows-gnu./x.py test library/std --target aarch64-apple-darwin
# All standard library tests./x.py test library/std# Specific test file./x.py test library/std --test-args vec# With output./x.py test library/std -- --nocapture