about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2022-07-28 22:14:46 +0530
committerGitHub <noreply@github.com>2022-07-28 22:14:46 +0530
commita479cab09a26149d84a5a4948d4738c365a1f26c (patch)
treebf1a1780e8354cf7b7c0e11ebcc20f6701d1547e
parente5682615bb4fdb90e3a37b810a1b7bded2a1199e (diff)
parent47a0a56c1d0b7c0d7825a86e8a7ef7dded99e958 (diff)
downloadrust-a479cab09a26149d84a5a4948d4738c365a1f26c.tar.gz
rust-a479cab09a26149d84a5a4948d4738c365a1f26c.zip
Rollup merge of #99628 - vincenzopalazzo:macros/is_number_doc, r=joshtriplett
add more docs regarding ideographic numbers

This was discussed in the last lib meeting and I try to avoid forgetting to open a PR because I think having some docs can help people.

However, I think we need to discuss a little bit if this is enough or if we need to add more clarification? Maybe an example?

Inspiration Source: https://github.com/rust-lang/rust/issues/84056#issuecomment-1184725924

Including suggestion https://github.com/rust-lang/rust/pull/99626#issuecomment-1192983043 my bad command git close the PR
-rw-r--r--library/core/src/char/methods.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/library/core/src/char/methods.rs b/library/core/src/char/methods.rs
index 0bec38a877e..eae567cad00 100644
--- a/library/core/src/char/methods.rs
+++ b/library/core/src/char/methods.rs
@@ -892,7 +892,16 @@ impl char {
     ///
     /// The general categories for numbers (`Nd` for decimal digits, `Nl` for letter-like numeric
     /// characters, and `No` for other numeric characters) are specified in the [Unicode Character
-    /// Database][ucd] [`UnicodeData.txt`].
+    /// Database][ucd] [`UnicodeData.txt`]. Note that this means ideographic numbers like '三'
+    /// are considered alphabetic, not numeric. Please consider to use `is_ascii_digit` or `is_digit`.
+    ///
+    /// This method doesn't cover everything that could be considered a number, e.g. ideographic numbers like '三'.
+    /// If you want everything including characters with overlapping purposes then you might want to use
+    /// a unicode or language-processing library that exposes the appropriate character properties instead
+    /// of looking at the unicode categories.
+    ///
+    /// If you want to parse ASCII decimal digits (0-9) or ASCII base-N, use
+    /// `is_ascii_digit` or `is_digit` instead.
     ///
     /// [Unicode Standard]: https://www.unicode.org/versions/latest/
     /// [ucd]: https://www.unicode.org/reports/tr44/
@@ -911,6 +920,7 @@ impl char {
     /// assert!(!'K'.is_numeric());
     /// assert!(!'و'.is_numeric());
     /// assert!(!'藏'.is_numeric());
+    /// assert!(!'三'.is_numeric());
     /// ```
     #[must_use]
     #[stable(feature = "rust1", since = "1.0.0")]