Skip to content

Commit 93cbf64

Browse files
committed
Fix errors + add mdbook version to travis.
1 parent 5be4ab3 commit 93cbf64

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ before_script:
55
- (test -x $HOME/.cargo/bin/cargo-install-update || cargo install cargo-update)
66
- (test -x $HOME/.cargo/bin/mdbook || cargo install mdbook)
77
- cargo install-update -a
8+
- mdbook --version
89
script:
910
- mdbook build
1011
- mdbook test

src/rust-2018/macros/macro-changes.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,16 @@ supporting both versions of rust more complicated.
8989
For example, let's make a simplified (and slightly contrived) version of the `log` crate in 2015
9090
edition style:
9191

92-
```rust,ignore
92+
```rust
9393
/// How important/severe the log message is.
9494
#[derive(Copy, Clone)]
95-
pub struct LogLevel {
95+
pub enum LogLevel {
9696
Warn,
9797
Error
9898
}
9999

100100
impl fmt::Display for LogLevel {
101-
pub fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
101+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
102102
match self {
103103
LogLevel::Warn => write!(f, "warning"),
104104
LogLevel::Error => write!(f, "error"),
@@ -159,7 +159,7 @@ which would make our code compile, but `__impl_log` is meant to be an implementa
159159
The cleanest way to handle this situation is to use the `$crate::` prefix for macros, the same as
160160
you would for any other path. Versions of the compiler >= 1.30 will handle this in both editions:
161161

162-
```rust,ignore
162+
```rust
163163
macro_rules! warn {
164164
($($args:tt)*) => {
165165
$crate::__impl_log!($crate::LogLevel::Warn, format_args!($($args)*))
@@ -193,7 +193,7 @@ solution is to add a level of indirection: we crate a macro that wraps `format_a
193193
to our crate. That way everything works in both editions (sadly we have to pollute the global
194194
namespace a bit, but that's ok).
195195

196-
```rust,ignore
196+
```rust
197197
// I've used the pattern `_<my crate name>__<macro name>` to name this macro, hopefully avoiding
198198
// name clashes.
199199
#[doc(hidden)]
@@ -211,15 +211,17 @@ whatever tokens we get to the inner macro, and rely on it to report errors.
211211
So the full 2015/2018 working example would be:
212212

213213
```rust
214+
use std::fmt;
215+
214216
/// How important/severe the log message is.
215-
#[derive(Copy, Clone)]
216-
pub struct LogLevel {
217+
#[derive(Debug, Copy, Clone)]
218+
pub enum LogLevel {
217219
Warn,
218220
Error
219221
}
220222

221223
impl fmt::Display for LogLevel {
222-
pub fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
224+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
223225
match self {
224226
LogLevel::Warn => write!(f, "warning"),
225227
LogLevel::Error => write!(f, "error"),

0 commit comments

Comments
 (0)