jiebi/CodeConvo huggingface dataset:
Repeat{element: elt} } <ins> /// An iterator that yields nothing. #[unstable(feature="iter_empty", reason = "new addition")] pub struct Empty<T>(marker::PhantomData<T>); #[unstable(feature="iter_empty", reason = "new addition")] impl<T> Iterator for Empty<T> { type Item = T; fn next(&mut self) -> Option<T> { None } fn size_hint(&self) -> (usize, Option<usize>){ (0, Some(0)) } } #[unstable(feature="iter_empty", reason = "new addition")] impl<T> DoubleEndedIterator for Empty<T> { fn next_back(&mut self) -> Option<T> { None } } #[unstable(feature="iter_empty", reason = "new addition")] impl<T> ExactSizeIterator for Empty<T> { fn len(&self) -> usize { 0 } } // not #[derive] because that adds a Clone bound on T, // which isn't necessary. #[unstable(feature="iter_empty", reason = "new addition")] impl<T> Clone for Empty<T> { fn clone(&self) -> Empty<T> { Empty(marker::PhantomData) } } // not #[derive] because that adds a Default bound on T, // which isn't necessary. #[unstable(feature="iter_empty", reason = "new addition")] impl<T> Default for Empty<T> { fn default() -> Empty<T> { Empty(marker::PhantomData) } } /// Creates an iterator that yields nothing. #[unstable(feature="iter_empty", reason = "new addition")] pub fn empty<T>() -> Empty<T> { Empty(marker::PhantomData) } /// An iterator that yields an element exactly once. #[unstable(feature="iter_once", reason = "new addition")] pub struct Once<T> { inner: ::option::IntoIter<T> } #[unstable(feature="iter_once", reason = "new addition")] impl<T> Iterator for Once<T> { type Item = T; fn next(&mut self) -> Option<T> { self.inner.next() } fn size_hint(&self) -> (usize, Option<usize>) { self.inner.size_hint() } } #[unstable(feature="iter_once", reason = "new addition")] impl<T> DoubleEndedIterator for Once<T> { fn next_back(&mut self) -> Option<T> { self.inner.next_back() } } #[unstable(feature="iter_once", reason = "new addition")] impl<T> ExactSizeIterator for Once<T> { fn len(&self) -> usize { self.inner.len() } } /// Creates an iterator that yields an element exactly once. #[unstable(feature="iter_once", reason = "new addition")] pub fn once<T>(value: T) -> Once<T> { Once { inner: Some(value).into_iter() } } </ins> /// Functions for lexicographical ordering of sequences. /// /// Lexicographical ordering through `<`, `<=`, `>=`, `>` requires
// Can't check len now because count consumes. } <ins> #[test] fn test_once() { let mut it = once(42); assert_eq!(it.next(), Some(42)); assert_eq!(it.next(), None); } #[test] fn test_empty() { let mut it = empty::<i32>(); assert_eq!(it.next(), None); } </ins> #[bench] fn bench_rposition(b: &mut Bencher) { let it: Vec<usize> = (0..300).collect();
T=$(command -v $P 2>&1) if [ $? -eq 0 ] then <del> VER0=$($P --version 2>/dev/null | head -1  |  sed -e 's/[^0-9]*([vV]?[0-9.]+[^ ]*).*/1/' ) </del> <ins> VER0=$($P --version 2>/dev/null  |  grep -o '[vV]?[0-9][0-9.][a-z0-9.-]*' | head -1 ) </ins> if [ $? -eq 0 -a "x${VER0}" != "x" ] then VER="($VER0)"
probe_need CFG_GIT     git fi <ins> # Use `md5sum` on GNU platforms, or `md5 -q` on BSD probe CFG_MD5              md5 probe CFG_MD5SUM           md5sum if [ -n "$CFG_MD5" ] then CFG_HASH_COMMAND="$CFG_MD5 -q | head -c 8" elif [ -n "$CFG_MD5SUM" ] then CFG_HASH_COMMAND="$CFG_MD5SUM | head -c 8" else err 'could not find one of: md5 md5sum' fi putvar CFG_HASH_COMMAND </ins> probe CFG_CLANG            clang++ probe CFG_CCACHE           ccache probe CFG_GCC              gcc
# versions (section 9) CFG_PRERELEASE_VERSION=.1 <del> CFG_FILENAME_EXTRA=4e7c5e5c </del> <ins> # Append a version-dependent hash to each library, so we can install different # versions in the same place CFG_FILENAME_EXTRA=$(shell printf '%s' $(CFG_RELEASE) | $(CFG_HASH_COMMAND)) </ins> ifeq ($(CFG_RELEASE_CHANNEL),stable) # This is the normal semver version string, e.g. "0.12.0", "0.12.0-nightly"
$(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log # As above but don't bother running tidy. <del> check-notidy: cleantmptestlogs cleantestlibs all check-stage2 </del> <ins> check-notidy: check-sanitycheck cleantmptestlogs cleantestlibs all check-stage2 </ins> $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log # A slightly smaller set of tests for smoke testing. <del> check-lite: cleantestlibs cleantmptestlogs  </del> <ins> check-lite: check-sanitycheck cleantestlibs cleantmptestlogs  </ins> $(foreach crate,$(TEST_TARGET_CRATES),check-stage2-$(crate))  check-stage2-rpass check-stage2-rpass-valgrind  check-stage2-rfail check-stage2-cfail check-stage2-pfail check-stage2-rmake $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log # Only check the 'reference' tests: rpass/cfail/rfail/rmake. <del> check-ref: cleantestlibs cleantmptestlogs check-stage2-rpass check-stage2-rpass-valgrind  check-stage2-rfail check-stage2-cfail check-stage2-pfail check-stage2-rmake </del> <ins> check-ref: check-sanitycheck cleantestlibs cleantmptestlogs check-stage2-rpass  check-stage2-rpass-valgrind check-stage2-rfail check-stage2-cfail check-stage2-pfail  check-stage2-rmake </ins> $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log # Only check the docs. <del> check-docs: cleantestlibs cleantmptestlogs check-stage2-docs </del> <ins> check-docs: check-sanitycheck cleantestlibs cleantmptestlogs check-stage2-docs </ins> $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log # Some less critical tests that are not prone to breakage.
set ALLOW_NONZERO_RLIMIT_CORE to ignore this warning """ % (soft)) <ins> @only_on(['win32']) def check_console_code_page(): if '65001' not in subprocess.check_output(['cmd', '/c', 'chcp']): sys.stderr.write('Warning: the console output code page is not UTF-8,  some tests may fail. Use `cmd /c "chcp 65001"` to setup UTF-8 code page.n') </ins> def main(): <ins> check_console_code_page() </ins> check_rlimit_core() if __name__ == '__main__':
<ins> // Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // ensure this code doesn't stack overflow // aux-build:enum_primitive.rs #[macro_use] extern crate enum_primitive; enum_from_primitive! { pub enum Test { A1,A2,A3,A4,A5,A6, B1,B2,B3,B4,B5,B6, C1,C2,C3,C4,C5,C6, D1,D2,D3,D4,D5,D6, E1,E2,E3,E4,E5,E6, F1,F2,F3,F4,F5,F6, G1,G2,G3,G4,G5,G6, H1,H2,H3,H4,H5,H6, I1,I2,I3,I4,I5,I6, J1,J2,J3,J4,J5,J6, K1,K2,K3,K4,K5,K6, L1,L2,L3,L4,L5,L6, M1,M2,M3,M4,M5,M6, N1,N2,N3,N4,N5,N6, O1,O2,O3,O4,O5,O6, P1,P2,P3,P4,P5,P6, Q1,Q2,Q3,Q4,Q5,Q6, R1,R2,R3,R4,R5,R6, S1,S2,S3,S4,S5,S6, T1,T2,T3,T4,T5,T6, U1,U2,U3,U4,U5,U6, V1,V2,V3,V4,V5,V6, W1,W2,W3,W4,W5,W6, X1,X2,X3,X4,X5,X6, Y1,Y2,Y3,Y4,Y5,Y6, Z1,Z2,Z3,Z4,Z5,Z6, } } </ins>
If you're on Windows, please download either the [32-bit installer][win32] or the [64-bit installer][win64] and run it. <del> [win32]: https://static.rust-lang.org/dist/rust-1.0.0-beta-i686-pc-windows-gnu.msi [win64]: https://static.rust-lang.org/dist/rust-1.0.0-beta-x86_64-pc-windows-gnu.msi </del> <ins> [win32]: https://static.rust-lang.org/dist/rust-1.0.0-i686-pc-windows-gnu.msi [win64]: https://static.rust-lang.org/dist/rust-1.0.0-x86_64-pc-windows-gnu.msi </ins> ## Uninstalling
You should see the version number, commit hash, commit date and build date: ```bash <del> rustc 1.0.0-beta (9854143cb 2015-04-02) (built 2015-04-02) </del> <ins> rustc 1.0.0 (a59de37e9 2015-05-13) (built 2015-05-14) </ins> ``` If you did, Rust has been installed successfully! Congrats!
str::from_utf8(&child_output.stdout).unwrap(), str::from_utf8(&child_output.stderr).unwrap())); <del> fs::remove_dir_all(&child_dir).unwrap(); </del> <ins> let res = fs::remove_dir_all(&child_dir); if res.is_err() { // On Windows deleting just executed mytest.exe can fail because it's still locked std::thread::sleep_ms(1000); fs::remove_dir_all(&child_dir).unwrap(); } </ins> }
of stdout", "PATH"), getopts::optflag("", "nocapture", "don't capture stdout/stderr of each  task, allow printing directly"), <ins> getopts::optopt("", "test-threads", "Number of threads used for running tests  in parallel", "n_threads"), </ins> getopts::optflag("q", "quiet", "Display one character per test instead of one line"), getopts::optopt("", "color", "Configure coloring of output: auto   = colorize if stdout is a tty and tests are run on serially (default);
tests whose names contain the filter are run. By default, all tests are run in parallel. This can be altered with the <del> RUST_TEST_THREADS environment variable when running tests (set it to 1). </del> <ins> --test-threads flag or the RUST_TEST_THREADS environment variable when running tests (set it to 1). </ins> All tests have their standard output and standard error captured by default. This can be overridden with the --nocapture flag or setting RUST_TEST_NOCAPTURE
}; } <ins> let test_threads = match matches.opt_str("test-threads") { Some(n_str) => match n_str.parse::<usize>() { Ok(n) => Some(n), Err(e) => return Some(Err(format!("argument for --test-threads must be a number > 0  (error: {})", e))) }, None => None, }; </ins> let color = match matches.opt_str("color").as_ref().map(|s| &**s) { Some("auto") | None => AutoColor, Some("always") => AlwaysColor,
dist-install-dir-$(1): PREPARE_LIB_CMD=$(DEFAULT_PREPARE_LIB_CMD) dist-install-dir-$(1): PREPARE_MAN_CMD=$(DEFAULT_PREPARE_MAN_CMD) dist-install-dir-$(1): PREPARE_CLEAN=true <del> dist-install-dir-$(1): prepare-base-dir-$(1) docs compiler-docs </del> <ins> dist-install-dir-$(1): prepare-base-dir-$(1) docs </ins> $$(Q)mkdir -p $$(PREPARE_DEST_DIR)/share/doc/rust $$(Q)$$(PREPARE_MAN_CMD) $$(S)COPYRIGHT $$(PREPARE_DEST_DIR)/share/doc/rust $$(Q)$$(PREPARE_MAN_CMD) $$(S)LICENSE-APACHE $$(PREPARE_DEST_DIR)/share/doc/rust
--legacy-manifest-dirs=rustlib,cargo $$(Q)rm -R tmp/dist/$$(PKG_NAME)-$(1)-image <del> dist-doc-install-dir-$(1): docs compiler-docs </del> <ins> dist-doc-install-dir-$(1): docs </ins> $$(Q)mkdir -p tmp/dist/$$(DOC_PKG_NAME)-$(1)-image/share/doc/rust $$(Q)cp -r doc tmp/dist/$$(DOC_PKG_NAME)-$(1)-image/share/doc/rust/html
[tuples]: primitive-types.html#tuples [enums]: enums.html <ins> # Ignoring bindings You can use `_` in a pattern to disregard the value. For example, here’s a `match` against a `Result<T, E>`: ```rust # let some_value: Result<i32, &'static str> = Err("There was an error"); match some_value { Ok(value) => println!("got a value: {}", value), Err(_) => println!("an error occurred"), } ``` In the first arm, we bind the value inside the `Ok` variant to `value`. But in the `Err` arm, we use `_` to disregard the specific error, and just print a general error message. `_` is valid in any pattern that creates a binding. This can be useful to ignore parts of a larger structure: ```rust fn coordinate() -> (i32, i32, i32) { // generate and return some sort of triple tuple # (1, 2, 3) } let (x, _, z) = coordinate(); ``` Here, we bind the first and last element of the tuple to `x` and `z`, but ignore the middle element. </ins> # Mix and Match Whew! That’s a lot of different ways to match things, and they can all be
use build_helper::output; <ins> #[cfg(not(target_os = "solaris"))] const SH_CMD: &'static str = "sh"; // On Solaris, sh is the historical bourne shell, not a POSIX shell, or bash. #[cfg(target_os = "solaris")] const SH_CMD: &'static str = "bash"; </ins> use {Build, Compiler, Mode}; use util::{cp_r, libdir, is_dylib, cp_filtered, copy};
let src = build.out.join(host).join("doc"); cp_r(&src, &dst); <del> let mut cmd = Command::new("sh"); </del> <ins> let mut cmd = Command::new(SH_CMD); </ins> cmd.arg(sanitize_sh(&build.src.join("src/rust-installer/gen-installer.sh"))) .arg("--product-name=Rust-Documentation") .arg("--rel-manifest-dir=rustlib")
.arg(host); build.run(&mut cmd); <del> let mut cmd = Command::new("sh"); </del> <ins> let mut cmd = Command::new(SH_CMD); </ins> cmd.arg(sanitize_sh(&build.src.join("src/rust-installer/gen-installer.sh"))) .arg("--product-name=Rust-MinGW") .arg("--rel-manifest-dir=rustlib")
let src = build.sysroot(compiler).join("lib/rustlib"); cp_r(&src.join(target), &dst); <del> let mut cmd = Command::new("sh"); </del> <ins> let mut cmd = Command::new(SH_CMD); </ins> cmd.arg(sanitize_sh(&build.src.join("src/rust-installer/gen-installer.sh"))) .arg("--product-name=Rust") .arg("--rel-manifest-dir=rustlib")
let image_src = src.join("save-analysis"); let dst = image.join("lib/rustlib").join(target).join("analysis"); t!(fs::create_dir_all(&dst)); <ins> println!("image_src: {:?}, dst: {:?}", image_src, dst); </ins> cp_r(&image_src, &dst); <del> let mut cmd = Command::new("sh"); </del> <ins> let mut cmd = Command::new(SH_CMD); </ins> cmd.arg(sanitize_sh(&build.src.join("src/rust-installer/gen-installer.sh"))) .arg("--product-name=Rust") .arg("--rel-manifest-dir=rustlib")
build.run(&mut cmd); // Create source tarball in rust-installer format <del> let mut cmd = Command::new("sh"); </del> <ins> let mut cmd = Command::new(SH_CMD); </ins> cmd.arg(sanitize_sh(&build.src.join("src/rust-installer/gen-installer.sh"))) .arg("--product-name=Rust") .arg("--rel-manifest-dir=rustlib")
input_tarballs.push_str(&sanitize_sh(&mingw_installer)); } <del> let mut cmd = Command::new("sh"); </del> <ins> let mut cmd = Command::new(SH_CMD); </ins> cmd.arg(sanitize_sh(&build.src.join("src/rust-installer/combine-installers.sh"))) .arg("--product-name=Rust") .arg("--rel-manifest-dir=rustlib")
This emphasizes that we have to go through the whole list of `chars`. <ins> ## Slicing You can get a slice of a string with slicing syntax: ```rust let dog = "hachiko"; let hachi = &dog[0..5]; ``` But note that these are _byte_ offsets, not _character_ offsets. So this will fail at runtime: ```rust,should_panic let dog = "忠犬ハチ公"; let hachi = &dog[0..2]; ``` with this error: ```text thread '<main>' panicked at 'index 0 and/or 2 in `忠犬ハチ公` do not lie on character boundary' ``` </ins> ## Concatenation If you have a `String`, you can concatenate a `&str` to the end of it:
} } <ins> // Format a number with thousands separators fn fmt_thousands_sep(mut n: usize, sep: char) -> String { use std::fmt::Write; let mut output = String::new(); let mut first = true; for &pow in &[9, 6, 3, 0] { let base = 10_usize.pow(pow); if pow == 0 || n / base != 0 { if first { output.write_fmt(format_args!("{}", n / base)).unwrap(); } else { output.write_fmt(format_args!("{:03}", n / base)).unwrap(); } if pow != 0 { output.push(sep); } first = false; } n %= base; } output } </ins> pub fn fmt_bench_samples(bs: &BenchSamples) -> String { <ins> use std::fmt::Write; let mut output = String::new(); let median = bs.ns_iter_summ.median as usize; let deviation = (bs.ns_iter_summ.max - bs.ns_iter_summ.min) as usize; output.write_fmt(format_args!("{:>11} ns/iter (+/- {})", fmt_thousands_sep(median, ','), fmt_thousands_sep(deviation, ','))).unwrap(); </ins> if bs.mb_s != 0 { <del> format!("{:>9} ns/iter (+/- {}) = {} MB/s", bs.ns_iter_summ.median as usize, (bs.ns_iter_summ.max - bs.ns_iter_summ.min) as usize, bs.mb_s) } else { format!("{:>9} ns/iter (+/- {})", bs.ns_iter_summ.median as usize, (bs.ns_iter_summ.max - bs.ns_iter_summ.min) as usize) </del> <ins> output.write_fmt(format_args!(" = {} MB/s", bs.mb_s)).unwrap(); </ins> } <ins> output </ins> } // A simple console test runner
strategy: fail-fast: false matrix: <del> build: [linux64, macos, win32] </del> include: <del> - build: linux64 os: ubuntu-latest </del> <ins> - os: ubuntu-latest </ins> host_target: x86_64-unknown-linux-gnu <del> - build: macos os: macos-latest </del> <ins> - os: macos-latest </ins> host_target: x86_64-apple-darwin <del> - build: win32 os: windows-latest </del> <ins> - os: windows-latest </ins> host_target: i686-pc-windows-msvc steps: - uses: actions/checkout@v3
this.write_bytes_ptr(ptr, iter::repeat(val_byte).take(byte_count.bytes_usize()))?; } <ins> "ptr_mask" => { let [ptr, mask] = check_arg_count(args)?; let ptr = this.read_pointer(ptr)?; let mask = this.read_scalar(mask)?.to_machine_usize(this)?; let masked_addr = Size::from_bytes(ptr.addr().bytes() & mask); this.write_pointer(Pointer::new(ptr.provenance, masked_addr), dest)?; } </ins> // Floating-point operations "fabsf32" => { let [f] = check_arg_count(args)?;
let [name] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?; let thread = this.pthread_self()?; let max_len = this.eval_libc("MAXTHREADNAMESIZE")?.to_machine_usize(this)?; <del> this.pthread_setname_np( </del> <ins> let res = this.pthread_setname_np( </ins> thread, this.read_scalar(name)?, max_len.try_into().unwrap(), )?; <ins> // Contrary to the manpage, `pthread_setname_np` on macOS still // returns an integer indicating success. this.write_scalar(res, dest)?; </ins> } "pthread_getname_np" => { let [thread, name, len] =
.chain(std::iter::repeat(" yada").take(100)) .collect::<String>(); <ins> fn set_thread_name(name: &CStr) -> i32 { #[cfg(target_os = "linux")] return unsafe { libc::pthread_setname_np(libc::pthread_self(), name.as_ptr().cast()) }; #[cfg(target_os = "macos")] return unsafe { libc::pthread_setname_np(name.as_ptr().cast()) }; } </ins> let result = thread::Builder::new().name(long_name.clone()).spawn(move || { // Rust remembers the full thread name itself. assert_eq!(thread::current().name(), Some(long_name.as_str()));
// But the system is limited -- make sure we successfully set a truncation. let mut buf = vec![0u8; long_name.len() + 1]; unsafe { <del> libc::pthread_getname_np(libc::pthread_self(), buf.as_mut_ptr().cast(), buf.len()); } </del> <ins> libc::pthread_getname_np(libc::pthread_self(), buf.as_mut_ptr().cast(), buf.len()) }; </ins> let cstr = CStr::from_bytes_until_nul(&buf).unwrap(); assert!(cstr.to_bytes().len() >= 15); // POSIX seems to promise at least 15 chars assert!(long_name.as_bytes().starts_with(cstr.to_bytes())); <ins> // Also test directly calling pthread_setname to check its return value. assert_eq!(set_thread_name(&cstr), 0); // But with a too long name it should fail. assert_ne!(set_thread_name(&CString::new(long_name).unwrap()), 0); </ins> }); result.unwrap().join().unwrap(); }
<ins> #![feature(ptr_mask)] #![feature(strict_provenance)] fn main() { let v: u32 = 0xABCDABCD; let ptr: *const u32 = &v; // u32 is 4 aligned, // so the lower `log2(4) = 2` bits of the address are always 0 assert_eq!(ptr.addr() & 0b11, 0); let tagged_ptr = ptr.map_addr(|a| a | 0b11); let tag = tagged_ptr.addr() & 0b11; let masked_ptr = tagged_ptr.mask(!0b11); assert_eq!(tag, 0b11); assert_eq!(unsafe { *masked_ptr }, 0xABCDABCD); } </ins>
concurrent code at compile time. Before we talk about the concurrency features that come with Rust, it's important <del> to understand something: Rust is low-level enough that all of this is provided by the standard library, not by the language. This means that if you don't like some aspect of the way Rust handles concurrency, you can implement an alternative way of doing things. [mio](https://github.com/carllerche/mio) is a real-world example of this principle in action. </del> <ins> to understand something: Rust is low-level enough that the vast majority of this is provided by the standard library, not by the language. This means that if you don't like some aspect of the way Rust handles concurrency, you can implement an alternative way of doing things. [mio](https://github.com/carllerche/mio) is a real-world example of this principle in action. </ins> ## Background: `Send` and `Sync`
} } <ins> impl fmt::Debug for Repr { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { match self { &Repr::Os(ref code) => fmt.debug_struct("Os").field("code", code) .field("message", &sys::os::error_string(*code)).finish(), &Repr::Custom(ref c) => fmt.debug_tuple("Custom").field(c).finish(), } } } </ins> #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for Error { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
use error; use error::Error as error_Error; use fmt; <ins> use sys::os::error_string; #[test] fn test_debug_error() { let code = 6; let msg = error_string(code); let err = Error { repr: super::Repr::Os(code) }; let expected = format!("Error {{ repr: Os {{ code: {:?}, message: {:?} }} }}", code, msg); assert_eq!(format!("{:?}", err), expected); } </ins> #[test] fn test_downcasting() {
/// A macro which expands to the line number on which it was invoked. /// <del> /// The expanded expression has type `usize`, and the returned line is not </del> <ins> /// The expanded expression has type `u32`, and the returned line is not </ins> /// the invocation of the `line!()` macro itself, but rather the first macro /// invocation leading up to the invocation of the `line!()` macro. ///
/// A macro which expands to the column number on which it was invoked. /// <del> /// The expanded expression has type `usize`, and the returned column is not </del> <ins> /// The expanded expression has type `u32`, and the returned column is not </ins> /// the invocation of the `column!()` macro itself, but rather the first macro /// invocation leading up to the invocation of the `column!()` macro. ///
/// /// - total and antisymmetric: exactly one of `a < b`, `a == b` or `a > b` is true; and /// - transitive, `a < b` and `b < c` implies `a < c`. The same must hold for both `==` and `>`. <ins> /// /// When this trait is `derive`d, it produces a lexicographic ordering. </ins> #[stable(feature = "rust1", since = "1.0.0")] pub trait Ord: Eq + PartialOrd<Self> { /// This method returns an `Ordering` between `self` and `other`.
<ins> // Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. pub trait Foo { type Input = usize; fn bar(&self, _: Self::Input) {} } impl Foo for () {} </ins>
<ins> // Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // aux-build:xcrate_associated_type_defaults.rs extern crate xcrate_associated_type_defaults; use xcrate_associated_type_defaults::Foo; fn main() { ().bar(5); } </ins>
match base_cmt.cat { mc::cat_upvar(mc::Upvar { id: ty::UpvarId { var_id: vid, .. }, .. }) | mc::cat_local(vid) => { <del> self.reassigned |= self.node == vid && Some(field) == self.field </del> <ins> self.reassigned |= self.node == vid && (self.field.is_none() || Some(field) == self.field) </ins> }, _ => {} }
<ins> // Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. fn main() { let mut c = (1, "".to_owned()); match c { c2 => { c.0 = 2; assert_eq!(c2.0, 1); } } } </ins>
// FOREIGN STATIC ITEM return Ok(Some(self.parse_item_foreign_static(visibility, lo, attrs)?)); } <del> if self.check_keyword(keywords::Fn) || self.check_keyword(keywords::Unsafe) { </del> <ins> if self.check_keyword(keywords::Fn) { </ins> // FOREIGN FUNCTION ITEM return Ok(Some(self.parse_item_foreign_fn(visibility, lo, attrs)?)); }