about summary refs log tree commit diff
path: root/src/libcore/char.rs
AgeCommit message (Collapse)AuthorLines
2018-04-12Move the core::char module to its own directorySimon Sapin-926/+0
2018-04-12Deprecate the std_unicode crateSimon Sapin-1/+1
2018-04-12Move char::REPLACEMENT_CHARACTER to libcoreSimon Sapin-0/+8
2018-03-31Auto merge of #49201 - Phlosioneer:add-trivial-size-hints, r=SimonSapinbors-0/+10
Implement some trivial size_hints for various iterators This also implements ExactSizeIterator where applicable. Addresses most of the Iterator traits mentioned in #23708. I intend to do more, but I don't want to make the PR too large.
2018-03-26Stabilize the TryFrom and TryInto traitsSimon Sapin-3/+3
Tracking issue: https://github.com/rust-lang/rust/issues/33417
2018-03-25Fix incorrect copy-pasted codePhlosioneer-3/+3
It's late.
2018-03-24Fix syntax errorPhlosioneer-1/+1
2018-03-24Fix incorrect lower boundsPhlosioneer-1/+6
2018-03-20Implement some trivial size_hints for various iteratorsPhlosioneer-0/+5
This also implements ExactSizeIterator where applicable. Addresses most of the Iterator traits mentioned in #23708.
2018-03-06Rollup merge of #47463 - bluss:fused-iterator, r=alexcrichtonkennytm-4/+4
Stabilize FusedIterator FusedIterator is a marker trait that promises that the implementing iterator continues to return `None` from `.next()` once it has returned `None` once (and/or `.next_back()`, if implemented). The effects of FusedIterator are already widely available through `.fuse()`, but with stable `FusedIterator`, stable Rust users can implement this trait for their iterators when appropriate. Closes #35602
2018-03-03core: Update stability attributes for FusedIteratorUlrik Sverdrup-4/+4
2018-03-03core: Stabilize FusedIteratorUlrik Sverdrup-4/+4
FusedIterator is a marker trait that promises that the implementing iterator continues to return `None` from `.next()` once it has returned `None` once (and/or `.next_back()`, if implemented). The effects of FusedIterator are already widely available through `.fuse()`, but with stable `FusedIterator`, stable Rust users can implement this trait for their iterators when appropriate.
2018-03-01Fix spelling s/casted/cast/Lukas Lueg-2/+2
2018-01-26derive PartialEq and Eq for `ParseCharError`tinaun-1/+1
unlike the other Parse*Error types, ParseCharError didn't have these implemented for whatever reason
2017-07-25std: Stabilize `char_escape_debug`Alex Crichton-5/+5
Stabilizes: * `<char>::escape_debug` * `std::char::EscapeDebug` Closes #35068
2017-07-10Correct some stability attributesOliver Middleton-3/+3
These show up in rustdoc so need to be correct.
2017-06-20added `FromStr` Impl for `char`tinaun-1/+58
2017-04-09Reduce str transmutes, add mut versions of methods.Clar Charr-1/+2
2017-03-29Fix typo in libcore/char.rsIrfan Hudda-1/+1
2017-03-20Fix up various linkssteveklabnik-2/+2
The unstable book, libstd, libcore, and liballoc all needed some adjustment.
2017-03-20Auto merge of #40281 - jimmycuadra:try-from-from-str, r=aturonbors-2/+2
Rename TryFrom's associated type and implement str::parse using TryFrom. Per discussion on the tracking issue, naming `TryFrom`'s associated type `Error` is generally more consistent with similar traits in the Rust ecosystem, and what people seem to assume it should be called. It also helps disambiguate from `Result::Err`, the most common "Err". See https://github.com/rust-lang/rust/issues/33417#issuecomment-269108968. `TryFrom<&str>` and `FromStr` are equivalent, so have the latter provide the former to ensure that. Using `TryFrom` in the implementation of `str::parse` means types that implement either trait can use it. When we're ready to stabilize `TryFrom`, we should update `FromStr` to suggest implementing `TryFrom<&str>` instead for new code. See https://github.com/rust-lang/rust/issues/33417#issuecomment-277175994 and https://github.com/rust-lang/rust/issues/33417#issuecomment-277253827. Refs #33417.
2017-03-15Rename TryFrom's associated type and implement str::parse using TryFrom.Jimmy Cuadra-2/+2
Per discussion on the tracking issue, naming `TryFrom`'s associated type `Error` is generally more consistent with similar traits in the Rust ecosystem, and what people seem to assume it should be called. It also helps disambiguate from `Result::Err`, the most common "Err". See https://github.com/rust-lang/rust/issues/33417#issuecomment-269108968. TryFrom<&str> and FromStr are equivalent, so have the latter provide the former to ensure that. Using TryFrom in the implementation of `str::parse` means types that implement either trait can use it. When we're ready to stabilize `TryFrom`, we should update `FromStr` to suggest implementing `TryFrom<&str>` instead for new code. See https://github.com/rust-lang/rust/issues/33417#issuecomment-277175994 and https://github.com/rust-lang/rust/issues/33417#issuecomment-277253827. Refs #33417.
2017-03-13Remove function invokation parens from documentation links.Corey Farwell-10/+10
This was never established as a convention we should follow in the 'More API Documentation Conventions' RFC: https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md
2017-01-29Fix a few impl stability attributesOliver Middleton-3/+3
The versions show up in rustdoc.
2017-01-11Implement Display for char Escape*, To*case.Clar Charr-1/+28
2016-12-15Stabilize std::char::{encode_utf8, encode_utf16}Aaron Turon-2/+2
2016-11-30Rename 'librustc_unicode' crate to 'libstd_unicode'.Corey Farwell-1/+1
Fixes #26554.
2016-11-23Use "radices" instead of "radicum"Sam Estep-1/+1
2016-09-28[breaking-change] std: change `encode_utf{8,16}()` to take a buffer and ↵tormol-119/+51
return a slice They panic if the buffer is too small.
2016-09-18Add missing Eq implementationsGuillaume Gomez-1/+1
2016-08-29Implement TryFrom<u32> for charSimon Sapin-6/+29
For symmetry with From<char> for u32.
2016-08-29Implement From<char> for u32, and From<u8> for charSimon Sapin-0/+34
These fit with other From implementations between integer types. This helps the coding style of avoiding the 'as' operator that sometimes silently truncates, and signals that these specific conversions are lossless and infaillible.
2016-08-25Auto merge of #35906 - jseyfried:local_prelude, r=eddybbors-2/+0
Use `#[prelude_import]` in `libcore` and `libstd` r? @eddyb
2016-08-25Rollup merge of #35947 - SimonSapin:decodeutf8-error-handling, r=alexcrichtonManish Goregaokar-13/+69
Yield Err in char::decode_utf8 per Unicode, like String::from_utf8_lossy r? @alexcrichton
2016-08-24Use `#[prelude_import]` in `libcore`.Jeffrey Seyfried-2/+0
2016-08-23Yield Err in char::decode_utf8 per Unicode, like String::from_utf8_lossySimon Sapin-13/+69
2016-08-18Add a FusedIterator trait.Steven Allen-0/+18
This trait can be used to avoid the overhead of a fuse wrapper when an iterator is already well-behaved. Conforming to: RFC 1581 Closes: #35602
2016-07-28Rename `char::escape` to `char::escape_debug` and add tracking issueTobias Bucher-12/+12
2016-07-26Restore `char::escape_default` and add `char::escape` insteadTobias Bucher-1/+37
2016-07-23Escape fewer Unicode codepoints in `Debug` impl of `str`Tobias Bucher-2/+3
Use the same procedure as Python to determine whether a character is printable, described in [PEP 3138]. In particular, this means that the following character classes are escaped: - Cc (Other, Control) - Cf (Other, Format) - Cs (Other, Surrogate), even though they can't appear in Rust strings - Co (Other, Private Use) - Cn (Other, Not Assigned) - Zl (Separator, Line) - Zp (Separator, Paragraph) - Zs (Separator, Space), except for the ASCII space `' '` (`0x20`) This allows for user-friendly inspection of strings that are not English (e.g. compare `"\u{e9}\u{e8}\u{ea}"` to `"éèê"`). Fixes #34318. [PEP 3138]: https://www.python.org/dev/peps/pep-3138/
2016-07-13add core::char::DecodeUtf8M Farkas-Dyck-0/+47
2016-05-26Explain the order of the enumeration itemsAndrea Canciani-0/+3
Simply a micro-optimization to reduce code size and to open up inlining opportunities.
2016-05-26Move length computation to `ExactSizeIterator` implsAndrea Canciani-24/+36
and reuse it in `size_hint`.
2016-05-26Implement `count` for `EscapeDefault` and `EscapeUnicode`Andrea Canciani-6/+7
Trivial implementation, as both are `ExactSizeIterator`s. Part of #24214.
2016-05-26`EscapeUnicode` and `EscapeDefault` are `ExactSizeIterator`sAndrea Canciani-0/+6
In #28662, `size_hint` was made exact for `EscapeUnicode` and `EscapeDefault`, but neither was marked as `ExactSizeIterator`.
2016-05-25Auto merge of #33699 - alexcrichton:stabilize-1.10, r=aturonbors-4/+2
std: Stabilize APIs for the 1.10 release This commit applies the FCP decisions made by the libs team for the 1.10 cycle, including both new stabilizations and deprecations. Specifically, the list of APIs is: Stabilized: * `os::windows::fs::OpenOptionsExt::access_mode` * `os::windows::fs::OpenOptionsExt::share_mode` * `os::windows::fs::OpenOptionsExt::custom_flags` * `os::windows::fs::OpenOptionsExt::attributes` * `os::windows::fs::OpenOptionsExt::security_qos_flags` * `os::unix::fs::OpenOptionsExt::custom_flags` * `sync::Weak::new` * `Default for sync::Weak` * `panic::set_hook` * `panic::take_hook` * `panic::PanicInfo` * `panic::PanicInfo::payload` * `panic::PanicInfo::location` * `panic::Location` * `panic::Location::file` * `panic::Location::line` * `ffi::CStr::from_bytes_with_nul` * `ffi::CStr::from_bytes_with_nul_unchecked` * `ffi::FromBytesWithNulError` * `fs::Metadata::modified` * `fs::Metadata::accessed` * `fs::Metadata::created` * `sync::atomic::Atomic{Usize,Isize,Bool,Ptr}::compare_exchange` * `sync::atomic::Atomic{Usize,Isize,Bool,Ptr}::compare_exchange_weak` * `collections::{btree,hash}_map::{Occupied,Vacant,}Entry::key` * `os::unix::net::{UnixStream, UnixListener, UnixDatagram, SocketAddr}` * `SocketAddr::is_unnamed` * `SocketAddr::as_pathname` * `UnixStream::connect` * `UnixStream::pair` * `UnixStream::try_clone` * `UnixStream::local_addr` * `UnixStream::peer_addr` * `UnixStream::set_read_timeout` * `UnixStream::set_write_timeout` * `UnixStream::read_timeout` * `UnixStream::write_Timeout` * `UnixStream::set_nonblocking` * `UnixStream::take_error` * `UnixStream::shutdown` * Read/Write/RawFd impls for `UnixStream` * `UnixListener::bind` * `UnixListener::accept` * `UnixListener::try_clone` * `UnixListener::local_addr` * `UnixListener::set_nonblocking` * `UnixListener::take_error` * `UnixListener::incoming` * RawFd impls for `UnixListener` * `UnixDatagram::bind` * `UnixDatagram::unbound` * `UnixDatagram::pair` * `UnixDatagram::connect` * `UnixDatagram::try_clone` * `UnixDatagram::local_addr` * `UnixDatagram::peer_addr` * `UnixDatagram::recv_from` * `UnixDatagram::recv` * `UnixDatagram::send_to` * `UnixDatagram::send` * `UnixDatagram::set_read_timeout` * `UnixDatagram::set_write_timeout` * `UnixDatagram::read_timeout` * `UnixDatagram::write_timeout` * `UnixDatagram::set_nonblocking` * `UnixDatagram::take_error` * `UnixDatagram::shutdown` * RawFd impls for `UnixDatagram` * `{BTree,Hash}Map::values_mut` * `<[_]>::binary_search_by_key` Deprecated: * `StaticCondvar` - this, and all other static synchronization primitives below, are usable today through the lazy-static crate on stable Rust today. Additionally, we'd like the non-static versions to be directly usable in a static context one day, so they're unlikely to be the final forms of the APIs in any case. * `CONDVAR_INIT` * `StaticMutex` * `MUTEX_INIT` * `StaticRwLock` * `RWLOCK_INIT` * `iter::Peekable::is_empty` Closes #27717 Closes #27720 Closes #30014 Closes #30425 Closes #30449 Closes #31190 Closes #31399 Closes #31767 Closes #32111 Closes #32281 Closes #32312 Closes #32551 Closes #33018
2016-05-24std: Stabilize APIs for the 1.10 releaseAlex Crichton-4/+2
This commit applies the FCP decisions made by the libs team for the 1.10 cycle, including both new stabilizations and deprecations. Specifically, the list of APIs is: Stabilized: * `os::windows::fs::OpenOptionsExt::access_mode` * `os::windows::fs::OpenOptionsExt::share_mode` * `os::windows::fs::OpenOptionsExt::custom_flags` * `os::windows::fs::OpenOptionsExt::attributes` * `os::windows::fs::OpenOptionsExt::security_qos_flags` * `os::unix::fs::OpenOptionsExt::custom_flags` * `sync::Weak::new` * `Default for sync::Weak` * `panic::set_hook` * `panic::take_hook` * `panic::PanicInfo` * `panic::PanicInfo::payload` * `panic::PanicInfo::location` * `panic::Location` * `panic::Location::file` * `panic::Location::line` * `ffi::CStr::from_bytes_with_nul` * `ffi::CStr::from_bytes_with_nul_unchecked` * `ffi::FromBytesWithNulError` * `fs::Metadata::modified` * `fs::Metadata::accessed` * `fs::Metadata::created` * `sync::atomic::Atomic{Usize,Isize,Bool,Ptr}::compare_exchange` * `sync::atomic::Atomic{Usize,Isize,Bool,Ptr}::compare_exchange_weak` * `collections::{btree,hash}_map::{Occupied,Vacant,}Entry::key` * `os::unix::net::{UnixStream, UnixListener, UnixDatagram, SocketAddr}` * `SocketAddr::is_unnamed` * `SocketAddr::as_pathname` * `UnixStream::connect` * `UnixStream::pair` * `UnixStream::try_clone` * `UnixStream::local_addr` * `UnixStream::peer_addr` * `UnixStream::set_read_timeout` * `UnixStream::set_write_timeout` * `UnixStream::read_timeout` * `UnixStream::write_Timeout` * `UnixStream::set_nonblocking` * `UnixStream::take_error` * `UnixStream::shutdown` * Read/Write/RawFd impls for `UnixStream` * `UnixListener::bind` * `UnixListener::accept` * `UnixListener::try_clone` * `UnixListener::local_addr` * `UnixListener::set_nonblocking` * `UnixListener::take_error` * `UnixListener::incoming` * RawFd impls for `UnixListener` * `UnixDatagram::bind` * `UnixDatagram::unbound` * `UnixDatagram::pair` * `UnixDatagram::connect` * `UnixDatagram::try_clone` * `UnixDatagram::local_addr` * `UnixDatagram::peer_addr` * `UnixDatagram::recv_from` * `UnixDatagram::recv` * `UnixDatagram::send_to` * `UnixDatagram::send` * `UnixDatagram::set_read_timeout` * `UnixDatagram::set_write_timeout` * `UnixDatagram::read_timeout` * `UnixDatagram::write_timeout` * `UnixDatagram::set_nonblocking` * `UnixDatagram::take_error` * `UnixDatagram::shutdown` * RawFd impls for `UnixDatagram` * `{BTree,Hash}Map::values_mut` * `<[_]>::binary_search_by_key` Deprecated: * `StaticCondvar` - this, and all other static synchronization primitives below, are usable today through the lazy-static crate on stable Rust today. Additionally, we'd like the non-static versions to be directly usable in a static context one day, so they're unlikely to be the final forms of the APIs in any case. * `CONDVAR_INIT` * `StaticMutex` * `MUTEX_INIT` * `StaticRwLock` * `RWLOCK_INIT` * `iter::Peekable::is_empty` Closes #27717 Closes #27720 cc #27784 (but encode methods still exist) Closes #30014 Closes #30425 Closes #30449 Closes #31190 Closes #31399 Closes #31767 Closes #32111 Closes #32281 Closes #32312 Closes #32551 Closes #33018
2016-04-20Implement `last` for `EscapeUnicode`Andrea Canciani-0/+12
Part of #24214.
2016-04-19Auto merge of #31253 - ranma42:improve-unicode-iter-offset, r=brsonbors-20/+32
Improve computation of offset in `EscapeUnicode` Unify the computation of `offset` and use `leading_zeros` instead of manually scanning the bits. This PR removes some duplicated code and makes it a little simpler . The computation of `offset` is also faster, but it is unlikely to have an impact on actual code. (split from #31049)
2016-03-22std: Change `encode_utf{8,16}` to return iteratorsAlex Crichton-70/+119
Currently these have non-traditional APIs which take a buffer and report how much was filled in, but they're not necessarily ergonomic to use. Returning an iterator which *also* exposes an underlying slice shouldn't result in any performance loss as it's just a lazy version of the same implementation, and it's also much more ergonomic! cc #27784