8
8
// option. This file may not be copied, modified, or distributed
9
9
// except according to those terms.
10
10
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
-
32
11
use borrow:: { Borrow , Cow , ToOwned } ;
33
12
use ffi:: CString ;
34
13
use fmt:: { self , Debug } ;
@@ -42,14 +21,29 @@ use vec::Vec;
42
21
use sys:: os_str:: { Buf , Slice } ;
43
22
use sys_common:: { AsInner , IntoInner , FromInner } ;
44
23
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.
46
40
#[ derive( Clone ) ]
47
41
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
48
42
pub struct OsString {
49
43
inner : Buf
50
44
}
51
45
52
- /// Slices into OS strings.
46
+ /// Slices into OS strings (see `OsString`) .
53
47
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
54
48
pub struct OsStr {
55
49
inner : Slice
0 commit comments