Skip to content

Commit 997a248

Browse files
author
Jonathan Turner
authored
Rollup merge of rust-lang#35610 - JessRudder:33637-doc-update-for-str-representaton, r=steveklabnik
Add note to docs for &str that example is to demo internals only r? @steveklabnik This adds a note below the &str representation example explaining that the example provided should not be used under normal circumstances.. Would it make sense to point people in the direction of the method(s) they should use instead? I left it out in the interest of not complicating the documentation, but, there's definitely an argument to be made for adding a bit of guidance in there.
2 parents b8859f6 + 758aff7 commit 997a248

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/libstd/primitive_docs.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,10 @@ mod prim_slice { }
385385
///
386386
/// [`.as_ptr()`]: #method.as_ptr
387387
/// [`len()`]: #method.len
388+
///
389+
/// Note: This example shows the internals of `&str`. `unsafe` should not be
390+
/// used to get a string slice under normal circumstances. Use `.as_slice()`
391+
/// instead.
388392
mod prim_str { }
389393

390394
#[doc(primitive = "tuple")]

0 commit comments

Comments
 (0)