Skip to content

Commit ecf3454

Browse files
committed
Fixed nits.
1 parent 69ac00a commit ecf3454

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

src/libcore/marker.rs

+24-23
Original file line numberDiff line numberDiff line change
@@ -351,33 +351,34 @@ pub trait PhantomFn<A:?Sized,R:?Sized=()> { }
351351
/// instance, it will behave *as if* an instance of the type `T` were
352352
/// present for the purpose of various automatic analyses.
353353
///
354-
/// # Example
354+
/// # Examples
355+
///
355356
/// When handling external resources over a foreign function interface,
356-
/// PhantomData can prevent mismatches by enforcing types in
357+
/// `PhantomData<T>` can prevent mismatches by enforcing types in
357358
/// the method implementations, although the struct doesn't actually
358359
/// contain values of the resource type.
359360
///
360-
///```
361-
///pub struct ExternalResource<R> {
362-
/// resource_handle: *mut (),
363-
/// resource_type: PhantomData<R>,
364-
///}
365-
///
366-
///impl<R: ResType> ExternalResource<R> {
367-
/// pub fn new() -> ExternalResource<R> {
368-
/// let size_of_res = mem::size_of::<R>();
369-
/// ExternalResource {
370-
/// resource_handle: foreign_lib::new(size_of_res),
371-
/// resource_type: PhantomData,
372-
/// }
373-
/// }
374-
///
375-
/// pub fn do_stuff(&self, param: ParamType) {
376-
/// let foreign_params = convert_params::<R>(param);
377-
/// foreign_lib::do_stuff(self.resource_handle, foreign_params);
378-
/// }
379-
///}
380-
///```
361+
```
362+
struct ExternalResource<R> {
363+
resource_handle: *mut (),
364+
resource_type: PhantomData<R>,
365+
}
366+
367+
impl<R: ResType> ExternalResource<R> {
368+
fn new() -> ExternalResource<R> {
369+
let size_of_res = mem::size_of::<R>();
370+
ExternalResource {
371+
resource_handle: foreign_lib::new(size_of_res),
372+
resource_type: PhantomData,
373+
}
374+
}
375+
376+
fn do_stuff(&self, param: ParamType) {
377+
let foreign_params = convert_params::<R>(param);
378+
foreign_lib::do_stuff(self.resource_handle, foreign_params);
379+
}
380+
}
381+
```
381382
///
382383
/// Another example: embedding a `PhantomData<T>` will inform the compiler
383384
/// that one or more instances of the type `T` could be dropped when

0 commit comments

Comments
 (0)