Description
The source code in the Rust Documentation can be executed using the Rust Playground by pressing the "Run" button, but the URL encoding of the %
symbol used is incorrect and will not execute correctly.
The %
is encoded as %%
, but the correct encoding is %25
.
For example, Vec retain has source code containing %
.
let mut vec = vec![1, 2, 3, 4];
vec.retain(|&x| x % 2 == 0);
assert_eq!(vec, [2, 4]);
https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.retain
This "Run" is linked to the following
https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn+main()+%7B%0Alet+mut+vec+=+vec!%5B1,+2,+3,+4%5D;%0Avec.retain(%7C%26x%7C+x+%%+2+==+0);%0Aassert_eq!(vec,+%5B2,+4%5D);%0A%7D&edition=2021
However, this does not work correctly. The correct way is as follows.
https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn+main()+%7B%0Alet+mut+vec+=+vec!%5B1,+2,+3,+4%5D;%0Avec.retain(%7C%26x%7C+x+%25+2+==+0);%0Aassert_eq!(vec,+%5B2,+4%5D);%0A%7D&edition=2021