Commit Graph

35 Commits

Author SHA1 Message Date
DaniPopes d5ff4f4f65 Simplify str::clone_into
Removes an `unsafe` in favor of just using `String` methods.
2024-06-25 22:34:41 +02:00
Marcondiro bbdf97254a fix #124714 str.to_lowercase sigma handling 2024-05-08 17:05:10 +02:00
Mark Rousskov bd7d328807 Replace version placeholders for 1.79 2024-05-01 21:01:51 -04:00
David Tolnay 61cf00464e Stabilize Utf8Chunks 2024-04-24 15:27:47 -07:00
David Tolnay f94a94227c Export core::str::from_raw_parts{,_mut} into alloc::str and std::str 2024-01-25 18:11:54 -08:00
Taras Tsugrii 785ebd9b21 [nit] Fix a comment typo. 2023-08-15 14:26:14 -05:00
Tshepang Mbambo 60e43bcf57 str.rs: remove "Basic usage" text
Only one example is given
2023-08-02 12:14:43 +02:00
Josh Soref 9cb9346005 Spelling library/
* advance
* aligned
* borrowed
* calculate
* debugable
* debuggable
* declarations
* desugaring
* documentation
* enclave
* ignorable
* initialized
* iterator
* kaboom
* monomorphization
* nonexistent
* optimizer
* panicking
* process
* reentrant
* rustonomicon
* the
* uninitialized

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-26 02:10:22 -04:00
Veera 9fe3a39e34 Improve documentation for str::replace() and str::replacen()
Currently, to know what the function will return when the pattern
doesn't match, the docs require the reader to understand the
implementation detail and mentally evaluate or run the example
code. It is not immediately clear.

This PR makes it more explicit so the reader can quickly find the
information.
2023-03-25 11:41:00 -04:00
Chayim Refael Friedman 8dbc878a35 Avoid unsafe code in to_ascii_[lower/upper]case() 2023-01-16 01:15:06 +02:00
Dylan DPC a4950ef7eb Rollup merge of #93162 - camsteffen:std-prim-docs, r=Mark-Simulacrum
Std module docs improvements

My primary goal is to create a cleaner separation between primitive types and primitive type helper modules (fixes #92777). I also changed a few header lines in other top-level std modules (seen at https://doc.rust-lang.org/std/) for consistency.

Some conventions used/established:

 * "The \`Box\<T>` type for heap allocation." - if a module mainly provides a single type, name it and summarize its purpose in the module header
 * "Utilities for the _ primitive type." - this wording is used for the header of helper modules
 * Documentation for primitive types themselves are removed from helper modules
 * provided-by-core functionality of primitive types is documented in the primitive type instead of the helper module (such as the "Iteration" section in the slice docs)

I wonder if some content in `std::ptr` should be in `pointer` but I did not address this.
2022-08-22 11:45:40 +05:30
Cameron Steffen 17ddcb434b Improve primitive/std docs separation and headers 2022-08-20 16:50:29 -05:00
dylni e8ee0b7b2b Expose Utf8Lossy as Utf8Chunks 2022-08-20 12:49:20 -04:00
bvanjoi 7c861cf0ad additional docs example for replace **all** of str 2022-06-10 00:28:46 +08:00
Conrad Ludgate d0f9930709 improve case conversion happy path 2022-05-26 13:18:57 +01:00
Pietro Albini 181d28bb61 trivial cfg(bootstrap) changes 2022-04-05 23:18:40 +02:00
lcnr afbecc0f68 remove now unnecessary lang items 2022-03-30 11:23:58 +02:00
lcnr bef6f3e895 rework implementation for inherent impls for builtin types 2022-03-30 11:23:58 +02:00
Ben Kimock 14f4ffae32 Use spare_capacity_mut instead of invalid unchecked indexing 2021-12-08 17:58:57 -05:00
mbartlett21 ed63c71d61 Fix str::SplitInclusive stabilisation date 2021-11-05 17:46:58 +10:00
John Kugelman fb2d0f5c03 Add #[must_use] to remaining alloc functions 2021-10-15 11:46:49 -04:00
John Kugelman 81eeb3e775 Fix uppercase/lowercase error 2021-10-12 08:53:54 -04:00
John Kugelman cf2bcd10ed Add #[must_use] to from_value conversions 2021-10-10 19:00:33 -04:00
John Kugelman 54d807cfc7 Add #[must_use] to string/char transformation methods
These methods could be misconstrued as modifying their arguments instead
of returning new values.

Where possible I made the note recommend a method that does mutate in
place.
2021-10-09 01:01:40 -04:00
Smitty bdfcb88e8b Use HTTPS links where possible 2021-06-23 16:26:46 -04:00
John Ericson 19be438cda alloc: Add unstable Cfg feature no-global_oom_handling
For certain sorts of systems, programming, it's deemed essential that
all allocation failures be explicitly handled where they occur. For
example, see Linus Torvald's opinion in [1]. Merely not calling global
panic handlers, or always `try_reserving` first (for vectors), is not
deemed good enough, because the mere presence of the global OOM handlers
is burdens static analysis.

One option for these projects to use rust would just be to skip `alloc`,
rolling their own allocation abstractions.  But this would, in my
opinion be a real shame. `alloc` has a few `try_*` methods already, and
we could easily have more. Features like custom allocator support also
demonstrate and existing to support diverse use-cases with the same
abstractions.

A natural way to add such a feature flag would a Cargo feature, but
there are currently uncertainties around how std library crate's Cargo
features may or not be stable, so to avoid any risk of stabilizing by
mistake we are going with a more low-level "raw cfg" token, which
cannot be interacted with via Cargo alone.

Note also that since there is no notion of "default cfg tokens" outside
of Cargo features, we have to invert the condition from
`global_oom_handling` to to `not(no_global_oom_handling)`. This breaks
the monotonicity that would be important for a Cargo feature (i.e.
turning on more features should never break compatibility), but it
doesn't matter for raw cfg tokens which are not intended to be
"constraint solved" by Cargo or anything else.

To support this use-case we create a new feature, "global-oom-handling",
on by default, and put the global OOM handler infra and everything else
it that depends on it behind it. By default, nothing is changed, but
users concerned about global handling can make sure it is disabled, and
be confident that all OOM handling is local and explicit.

For this first iteration, non-flat collections are outright disabled.
`Vec` and `String` don't yet have `try_*` allocation methods, but are
kept anyways since they can be oom-safely created "from parts", and we
hope to add those `try_` methods in the future.

[1]: https://lore.kernel.org/lkml/CAHk-=wh_sNLoz84AUUzuqXEsYH35u=8HV3vK-jbRbJ_B-JjGrg@mail.gmail.com/
2021-05-05 16:49:04 -04:00
bors 5208f63ba8 Auto merge of #81728 - Qwaz:fix-80335, r=joshtriplett
Fixes API soundness issue in join()

Fixes #80335
2021-03-28 06:32:34 +00:00
David Tolnay 633a66fb66 Bump alloc::str::SplitInclusive to 1.53.0 release 2021-03-23 20:26:19 -07:00
Ian Jackson 52dc0718c0 Expose str::SplitInclusive in alloc and therefore in std
This seems to have been omitted from the beginning when this feature
was first introduced in 86bf96291d.

Most users won't need to name this type which is probably why this
wasn't noticed in the meantime.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-03-23 11:57:03 +00:00
Yechan Bae 26a62701e4 Update the comment 2021-03-20 13:42:54 -04:00
Joshua Nelson 9a75f4fed1 Convert primitives to use intra-doc links 2021-02-25 20:31:53 -05:00
Yechan Bae 6d43225bfb Fixes #80335 2021-02-03 16:36:33 -05:00
Camelid 0506789014 Remove many unnecessary manual link resolves from library
Now that #76934 has merged, we can remove a lot of these! E.g, this is
no longer necessary:

    [`Vec<T>`]: Vec
2020-12-31 11:54:32 -08:00
Aleksey Kladov 88da5682c3 Privatize some of libcore unicode_internals
My understanding is that these API are perma unstable, so it doesn't
make sense to pollute docs & IDE completion[1] with them.

[1]: https://github.com/rust-analyzer/rust-analyzer/issues/6738
2020-12-07 16:16:42 +03:00
mark 2c31b45ae8 mv std libs to library/ 2020-07-27 19:51:13 -05:00