Skip to content

Commit 3f26bf6

Browse files
committed
Add header and badges to README
1 parent a436674 commit 3f26bf6

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
1+
# ``objc-encode``
2+
3+
[![Crates.io](https://img.shields.io/crates/v/objc-encode.svg)](https://crates.io/crates/objc-encode)
4+
[![Docs.rs](https://docs.rs/objc-encode/badge.svg)](https://docs.rs/objc-encode/)
5+
16
Objective-C type encoding creation and parsing in Rust.
27

38
The Objective-C compiler encodes types as strings for usage in the runtime.
49
This crate aims to provide a strongly-typed (rather than stringly-typed) way
510
to create and describe these type encodings without memory allocation in Rust.
611

7-
# Implementing Encode
12+
13+
## Implementing Encode
814

915
This crate declares an `Encode` trait that can be implemented for types that
1016
the Objective-C compiler can encode. Implementing this trait looks like:
1117

12-
``` rust
18+
```rust
1319
unsafe impl Encode for CGPoint {
1420
const ENCODING: Encoding<'static> =
1521
Encoding::Struct("CGPoint", &[CGFloat::ENCODING, CGFLOAT::ENCODING]);
@@ -19,20 +25,20 @@ unsafe impl Encode for CGPoint {
1925
For an example of how this works with more complex types, like structs
2026
containing structs, see the `core_graphics` example.
2127

22-
# Comparing with encoding strings
28+
## Comparing with encoding strings
2329

2430
An `Encoding` can be compared with an encoding string from the Objective-C
2531
runtime:
2632

27-
``` rust
33+
```rust
2834
assert!(&i32::ENCODING == "i");
2935
```
3036

31-
# Generating encoding strings
37+
## Generating encoding strings
3238

3339
Every `Encoding` implements `Display` as its string representation.
3440
This can be generated conveniently through the `to_string` method:
3541

36-
``` rust
42+
```rust
3743
assert_eq!(i32::ENCODING.to_string(), "i");
3844
```

0 commit comments

Comments
 (0)