File tree 1 file changed +4
-4
lines changed
1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change 73
73
//!
74
74
//! ```c
75
75
//! /* C header */
76
- //!
76
+ //!
77
77
//! /* Returns ownership to the caller */
78
78
//! struct Foo* foo_new(void);
79
- //!
79
+ //!
80
80
//! /* Takes ownership from the caller; no-op when invoked with NULL */
81
81
//! void foo_delete(struct Foo*);
82
82
//! ```
83
- //!
83
+ //!
84
84
//! These two functions might be implemented in Rust as follows. Here, the
85
85
//! `struct Foo*` type from C is translated to `Box<Foo>`, which captures
86
86
//! the ownership constraints. Note also that the nullable argument to
99
99
//! #[no_mangle]
100
100
//! pub extern "C" fn foo_delete(_: Option<Box<Foo>>) {}
101
101
//! ```
102
- //!
102
+ //!
103
103
//! Even though `Box<T>` has the same representation and C ABI as a C pointer,
104
104
//! this does not mean that you can convert an arbitrary `T*` into a `Box<T>`
105
105
//! and expect things to work. `Box<T>` values will always be fully aligned,
You can’t perform that action at this time.
0 commit comments