Trevor Spiteri
b70a9532a9
Replace s with self in docs for str methods taking self.
2019-02-27 17:07:35 +01:00
kennytm
e3a8f7db47
Rollup merge of #58553 - scottmcm:more-ihle, r=Centril
...
Use more impl header lifetime elision
Inspired by seeing explicit lifetimes on these two:
- https://doc.rust-lang.org/nightly/std/slice/struct.Iter.html#impl-FusedIterator
- https://doc.rust-lang.org/nightly/std/primitive.u32.html#impl-Not
And a follow-up to https://github.com/rust-lang/rust/pull/54687 , that started using IHLE in libcore.
Most of the changes in here fall into two big categories:
- Removing lifetimes from common traits that can essentially never user a lifetime from an input (particularly `Drop`, `Debug`, and `Clone`)
- Forwarding impls that are only possible because the lifetime doesn't matter (like `impl<R: Read + ?Sized> Read for &mut R`)
I omitted things that seemed like they could be more controversial, like the handful of iterators that have a `Item: 'static` despite the iterator having a lifetime or the `PartialEq` implementations [where the flipped one cannot elide the lifetime](https://internals.rust-lang.org/t/impl-type-parameter-aliases/9403/2?u=scottmcm ).
I also removed two lifetimes that turned out to be completely unused; see https://github.com/rust-lang/rust/issues/41960#issuecomment-464557423
2019-02-20 11:59:10 +08:00
Scott McMurray
3bea2ca49d
Use more impl header lifetime elision
...
There are two big categories of changes in here
- Removing lifetimes from common traits that can essentially never user a lifetime from an input (particularly `Drop` & `Debug`)
- Forwarding impls that are only possible because the lifetime doesn't matter (like `impl<R: Read + ?Sized> Read for &mut R`)
I omitted things that seemed like they could be more controversial, like the handful of iterators that have a `Item: 'static` despite the iterator having a lifetime or the `PartialEq` implementations where the flipped one cannot elide the lifetime.
2019-02-17 19:42:36 -08:00
Mazdak Farrokhzad
ecb6503169
Rollup merge of #58200 - RalfJung:str-as-mut-ptr, r=SimonSapin
...
fix str mutating through a ptr derived from &self
Found by Miri: In `get_unchecked_mut` (also used by the checked variants internally) uses `str::as_ptr` to create a mutable reference, but `as_ptr` takes `&self`. This means the mutable references we return here got created from a shared reference, which violates the shared-references-are-read-only discipline!
For this by using a newly introduced `as_mut_ptr` instead.
2019-02-13 04:37:03 +01:00
bors
0f949c2fcc
Auto merge of #58051 - SimonSapin:str_escape, r=alexcrichton
...
Stabilize str::escape_* methods with new return types…
… that implement `Display` and `Iterator<Item=char>`, as proposed in FCP: https://github.com/rust-lang/rust/issues/27791#issuecomment-376864727
2019-02-12 23:30:16 +00:00
Simon Sapin
eb158f9350
Add doctests for str::escape_*
2019-02-12 09:55:30 +01:00
Simon Sapin
92cce78d06
Move str::escape_* to libcore
2019-02-12 09:55:30 +01:00
Simon Sapin
92dcae4742
Add internal impl_fn_for_zst macro for "named closure types"
2019-02-12 09:55:20 +01:00
Alexander Regueiro
99ed06eb88
libs: doc comments
2019-02-10 23:57:25 +00:00
Alexander Regueiro
b87363e763
tests: doc comments
2019-02-10 23:42:32 +00:00
Alexander Regueiro
c3e182cf43
rustc: doc comments
2019-02-10 23:42:32 +00:00
Ralf Jung
66c894e07f
also fix bad use of shared ref in split_at_mut
2019-02-07 17:55:42 +01:00
Ralf Jung
a996f2c8dc
add tracking issue
2019-02-06 12:55:50 +01:00
Ralf Jung
13bbba273c
remove now-unneeded raw ptr casts
2019-02-06 11:23:10 +01:00
Ralf Jung
346dc37aee
fix str mutating through a ptr derived from &self
2019-02-05 20:07:45 +01:00
garyemerson
75b19579fb
update split docs
...
Some confusion about split popped up at https://news.ycombinator.com/item?id=19080931 since the docs sorta sound like `&str`, `char` and closures are the only types that can be patterns.
cc @steveklabnik
2019-02-04 15:26:33 -08:00
Simon Sapin
6a01f8aecd
Stabilize split_ascii_whitespace
...
Tracking issue FCP to merge: https://github.com/rust-lang/rust/issues/48656#issuecomment-442372750
2019-02-01 11:24:12 +01:00
Mazdak Farrokhzad
c76456c253
Rollup merge of #58005 - vitiral:docs_trim_start_matches, r=Manishearth
...
update docs for fix_start/end_matches
fixes #57686 :
2019-01-31 02:10:51 +01:00
Mazdak Farrokhzad
7ebb0a8c8e
Rollup merge of #57106 - matthiaskrgr:trim_must_use, r=sfackler
...
Mark str::trim.* functions as #[must_use].
The functions return a reference to a new object and do not modify in-place
as the following code shows:
````
let s = String::from(" hello ");
s.trim();
assert_eq!(s, " hello ");
````
The new reference should be bound to a variable as now indicated by #[must_use].
2019-01-31 02:10:41 +01:00
Rett Berg
4a3caca978
fix #57686 : update docs for fix_start/end_matches
2019-01-30 10:12:49 -08:00
Clar Fon
520e8b001e
Move TrustedRandomAccess into Zip module
2019-01-22 17:45:11 -05:00
Alexis Hunt
c7d25a2a40
Make str indexing generic on SliceIndex.
2019-01-19 04:16:05 -05:00
Steve Klabnik
beb6495862
note that FromStr does not work for borrowed types
...
Fixes #47757
2019-01-10 17:08:27 -05:00
Matthias Krüger
74e9057905
modify remaining #[must_use[ messages
2018-12-26 22:03:04 +01:00
Zack M. Davis
e7ce868f8e
Update src/libcore/str/mod.rs, tweak must_use message
...
trimmed string is returned as a slice instead of a new allocation
Co-Authored-By: matthiaskrgr <matthias.krueger@famsik.de>
2018-12-26 20:01:52 +01:00
Matthias Krüger
809a1a86e0
mark str::string::String.trim.* functions as #[must_use].
...
The functions return a reference to a new object and do not modify in-place
as the following code shows:
````
let s = String::from(" hello ");
s.trim();
assert_eq!(s, " hello ");
````
The new reference should be bound to a variable as now indicated by #[must_use].
2018-12-26 20:01:52 +01:00
Mark Rousskov
2a663555dd
Remove licenses
2018-12-25 21:08:33 -07:00
Alexander Regueiro
ee89c088b0
Various minor/cosmetic improvements to code
2018-12-07 23:53:34 +00:00
Pietro Albini
64371f1cfe
Rollup merge of #56119 - frewsxcv:frewsxcv-option-carrier, r=TimNN
...
Utilize `?` instead of `return None`.
None
2018-12-05 23:54:25 +01:00
Corey Farwell
9012af6f19
Utilize ? instead of return None.
2018-12-04 08:57:34 -08:00
Adrian Heine né Lang
37f719e0d3
std::str Adapt documentation to reality
2018-11-22 15:26:16 +01:00
kennytm
5ccc76fe5c
Rollup merge of #55870 - waywardmonkeys:typo-fixes, r=wesleywiser
...
Fix typos.
2018-11-13 19:20:44 +08:00
Bruce Mitchener
a62af858e0
Fix typos.
2018-11-11 20:52:36 +07:00
Mazdak Farrokhzad
e15c62d61f
revert making internal APIs const fn.
2018-11-10 01:10:07 +01:00
Mazdak Farrokhzad
d1d2aa22c0
reduce list to functions callable in const ctx.
2018-11-10 01:10:07 +01:00
Mazdak Farrokhzad
5b89877dda
constify parts of libcore.
2018-11-10 01:07:32 +01:00
Scott McMurray
0a3bd9b6ab
Use impl_header_lifetime_elision in libcore
2018-09-29 21:33:35 -07:00
bors
8b7f164eab
Auto merge of #52994 - varkor:trim_direction, r=alexcrichton
...
Add trim_start, trim_end etc.; deprecate trim_left, trim_right, etc. in future
Adds the methods: `trim_start`, `trim_end`, `trim_start_matches` and `trim_end_matches`.
Deprecates `trim_left`, `trim_right`, `trim_left_matches` and `trim_right_matches` starting from Rust 1.33.0, three versions from when they'll initially be marked as being deprecated, using the future deprecation from https://github.com/rust-lang/rust/issues/30785 and https://github.com/rust-lang/rust/pull/51681 .
Fixes https://github.com/rust-lang/rust/issues/30459 .
2018-09-05 23:45:08 +00:00
Matthias Krüger
e699076780
use char pattern for single-character splits: a.split("x") -> a.split('x')
2018-08-22 12:56:32 +02:00
Corey Farwell
993fb93464
Replace usages of ptr::offset with ptr::{add,sub}.
2018-08-20 07:28:34 -04:00
Guillaume Gomez
f618071c46
Rollup merge of #53273 - frewsxcv:frewsxcv-ufffd, r=GuillaumeGomez
...
Add links to std::char::REPLACEMENT_CHARACTER from docs.
There are a few places where we mention the replacement character in the
docs, and it could be helpful for users to utilize the constant which is
available in the standard library, so let’s link to it!
2018-08-12 23:27:04 +02:00
Guillaume Gomez
28e1a7ba5e
Rollup merge of #53059 - ljedrz:unneeded_returns, r=kennytm
...
Remove explicit returns where unnecessary
2018-08-12 23:26:51 +02:00
Corey Farwell
ec18991492
Add links to std::char::REPLACEMENT_CHARACTER from docs.
...
There are a few places where we mention the replacement character in the
docs, and it could be helpful for users to utilize the constant which is
available in the standard library, so let’s link to it!
2018-08-11 15:42:35 -04:00
varkor
3e10ffcb81
Make features stable and clarify examples
2018-08-05 22:48:30 +01:00
ljedrz
1667950d73
Remove explicit returns where unnecessary
2018-08-04 14:31:03 +02:00
redroc
616970758b
deleted changed lines
2018-08-04 05:51:02 +02:00
redroc
33483fa0e3
fixed broken links to char
2018-08-04 03:36:58 +02:00
varkor
33067ad201
Add #![feature(trim_direction)] to doc comments
2018-08-02 22:00:13 +01:00
varkor
aecf8c2a62
Add trim_start, trim_end, trim_start_matches and trim_end_matches
2018-08-02 20:39:29 +01:00
Colin Wallace
727bd7de7e
libcore: Prefer Option::map over match where applicable
2018-07-23 22:04:33 -07:00