File tree 3 files changed +13
-24
lines changed
3 files changed +13
-24
lines changed Original file line number Diff line number Diff line change @@ -34,17 +34,8 @@ assert!(parsed == &i32::encode());
34
34
35
35
# Generating encoding strings
36
36
37
- The string representation of an ` Encoding ` can be generated via its ` write `
38
- method:
39
-
40
- ``` rust
41
- let mut result = String :: new ();
42
- i32 :: encode (). write (& mut result ). unwrap ();
43
- assert_eq! (result , " i" );
44
- ```
45
-
46
- The encodings defined in this crate also implement ` Display ` for convenience,
47
- allowing the ` to_string ` method to be used:
37
+ Every ` Encoding ` implements ` Display ` as its string representation.
38
+ This can be generated conveniently through the ` to_string ` method:
48
39
49
40
``` rust
50
41
assert_eq! (i32 :: encode (). to_string (), " i" );
Original file line number Diff line number Diff line change
1
+ use core:: fmt;
2
+
1
3
use { Descriptor , Encoding } ;
2
4
use multi:: { Encodings , EncodingsIterateCallback } ;
3
5
@@ -24,3 +26,9 @@ impl Encodings for Never {
24
26
match self { }
25
27
}
26
28
}
29
+
30
+ impl fmt:: Display for Never {
31
+ fn fmt ( & self , _: & mut fmt:: Formatter ) -> fmt:: Result {
32
+ match self { }
33
+ }
34
+ }
Original file line number Diff line number Diff line change @@ -37,18 +37,8 @@ assert!(parsed == &i32::encode());
37
37
38
38
# Generating encoding strings
39
39
40
- The string representation of an `Encoding` can be generated via its `write`
41
- method:
42
-
43
- ```
44
- # use objc_encode::{Encode, Encoding};
45
- let mut result = String::new();
46
- i32::encode().write(&mut result).unwrap();
47
- assert_eq!(result, "i");
48
- ```
49
-
50
- The encodings defined in this crate also implement `Display` for convenience,
51
- allowing the `to_string` method to be used:
40
+ Every `Encoding` implements `Display` as its string representation.
41
+ This can be generated conveniently through the `to_string` method:
52
42
53
43
```
54
44
# use objc_encode::Encode;
@@ -75,7 +65,7 @@ pub use descriptor::Descriptor;
75
65
pub use multi:: { Encodings , EncodingsIterateCallback } ;
76
66
77
67
/// An Objective-C type encoding.
78
- pub trait Encoding {
68
+ pub trait Encoding : fmt :: Display {
79
69
/// The type of `Encoding` that Self will use if it is an encoding for
80
70
/// a pointer to describe its target.
81
71
type PointerTarget : ?Sized + Encoding ;
You can’t perform that action at this time.
0 commit comments