Closed
Description
Suppose we have this trait:
// lib.rs
pub trait Trait {
fn method<T>()
where
T: Default;
}
Run cargo doc
; it renders as:
Now let's begin writing an impl of this trait:
struct MyStruct;
impl Trait for MyStruct {
}
and copy in the method
method signature directly from the documentation:
struct MyStruct;
impl Trait for MyStruct {
fn method<T>()
where
T: Default {}
}
We get this distressing error from cargo check
:
error: unknown start of token: \u{a0}
--> src/main.rs:11:1
|
11 | where
| ^
|
help: Unicode character ' ' (No-Break Space) looks like ' ' (Space), but it is not
|
11 | where
| +
error: unknown start of token: \u{a0}
--> src/main.rs:11:2
|
11 | where
| ^
|
help: Unicode character ' ' (No-Break Space) looks like ' ' (Space), but it is not
|
11 | where
| +
error: unknown start of token: \u{a0}
--> src/main.rs:11:3
|
11 | where
| ^
|
help: Unicode character ' ' (No-Break Space) looks like ' ' (Space), but it is not
|
11 | where
| +
error: unknown start of token: \u{a0}
--> src/main.rs:11:4
|
11 | where
| ^
|
help: Unicode character ' ' (No-Break Space) looks like ' ' (Space), but it is not
|
11 | where
| +
error: unknown start of token: \u{a0}
--> src/main.rs:12:1
|
12 | T: Default {}
| ^
|
help: Unicode character ' ' (No-Break Space) looks like ' ' (Space), but it is not
|
12 | T: Default {}
| +
error: unknown start of token: \u{a0}
--> src/main.rs:12:2
|
12 | T: Default {}
| ^
|
help: Unicode character ' ' (No-Break Space) looks like ' ' (Space), but it is not
|
12 | T: Default {}
| +
error: unknown start of token: \u{a0}
--> src/main.rs:12:3
|
12 | T: Default {}
| ^
|
help: Unicode character ' ' (No-Break Space) looks like ' ' (Space), but it is not
|
12 | T: Default {}
| +
error: unknown start of token: \u{a0}
--> src/main.rs:12:4
|
12 | T: Default {}
| ^
|
help: Unicode character ' ' (No-Break Space) looks like ' ' (Space), but it is not
|
12 | T: Default {}
| +
error: unknown start of token: \u{a0}
--> src/main.rs:12:5
|
12 | T: Default {}
| ^
|
help: Unicode character ' ' (No-Break Space) looks like ' ' (Space), but it is not
|
12 | T: Default {}
| +
error: unknown start of token: \u{a0}
--> src/main.rs:12:6
|
12 | T: Default {}
| ^
|
help: Unicode character ' ' (No-Break Space) looks like ' ' (Space), but it is not
|
12 | T: Default {}
| +
error: unknown start of token: \u{a0}
--> src/main.rs:12:7
|
12 | T: Default {}
| ^
|
help: Unicode character ' ' (No-Break Space) looks like ' ' (Space), but it is not
|
12 | T: Default {}
| +
error: unknown start of token: \u{a0}
--> src/main.rs:12:8
|
12 | T: Default {}
| ^
|
help: Unicode character ' ' (No-Break Space) looks like ' ' (Space), but it is not
|
12 | T: Default {}
| +
Hopefully there is some other way rustdoc would be able to display the same content in a way that doesn't suffer this limitation.
Is this just as simple as using white-space: pre;
in the CSS and then writing ordinary spaces instead of ? If so, that seems definitely worthwhile doing.