88// option. This file may not be copied, modified, or distributed
99// except according to those terms.
1010
11- //! A type that can represent all platform-native strings, but is cheaply
12- //! interconvertable with Rust strings.
13- //!
14- //! The need for this type arises from the fact that:
15- //!
16- //! * On Unix systems, strings are often arbitrary sequences of non-zero
17- //! bytes, in many cases interpreted as UTF-8.
18- //!
19- //! * On Windows, strings are often arbitrary sequences of non-zero 16-bit
20- //! values, interpreted as UTF-16 when it is valid to do so.
21- //!
22- //! * In Rust, strings are always valid UTF-8, but may contain zeros.
23- //!
24- //! The types in this module bridge this gap by simultaneously representing Rust
25- //! and platform-native string values, and in particular allowing a Rust string
26- //! to be converted into an "OS" string with no cost.
27- //!
28- //! **Note**: At the moment, these types are extremely bare-bones, usable only
29- //! for conversion to/from various other string types. Eventually these types
30- //! will offer a full-fledged string API.
31-
3211use borrow:: { Borrow , Cow , ToOwned } ;
3312use ffi:: CString ;
3413use fmt:: { self , Debug } ;
@@ -42,14 +21,29 @@ use vec::Vec;
4221use sys:: os_str:: { Buf , Slice } ;
4322use sys_common:: { AsInner , IntoInner , FromInner } ;
4423
45- /// Owned, mutable OS strings.
24+ /// A type that can represent owned, mutable platform-native strings, but is
25+ /// cheaply interconvertable with Rust strings.
26+ ///
27+ /// The need for this type arises from the fact that:
28+ ///
29+ /// * On Unix systems, strings are often arbitrary sequences of non-zero
30+ /// bytes, in many cases interpreted as UTF-8.
31+ ///
32+ /// * On Windows, strings are often arbitrary sequences of non-zero 16-bit
33+ /// values, interpreted as UTF-16 when it is valid to do so.
34+ ///
35+ /// * In Rust, strings are always valid UTF-8, but may contain zeros.
36+ ///
37+ /// `OsString` and `OsStr` bridge this gap by simultaneously representing Rust
38+ /// and platform-native string values, and in particular allowing a Rust string
39+ /// to be converted into an "OS" string with no cost.
4640#[ derive( Clone ) ]
4741#[ stable( feature = "rust1" , since = "1.0.0" ) ]
4842pub struct OsString {
4943 inner : Buf
5044}
5145
52- /// Slices into OS strings.
46+ /// Slices into OS strings (see `OsString`) .
5347#[ stable( feature = "rust1" , since = "1.0.0" ) ]
5448pub struct OsStr {
5549 inner : Slice
0 commit comments