1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-06-28 03:28:32 +02:00

Skip some untranslatable code blocks (#1258)

This builds on the work of @dyoo in
https://github.com/google/mdbook-i18n-helpers/pull/69: by adding a
special `<!-- mdbook-xgettext: skip -->` comment, we can skip the
following code block.

I also modified a few code blocks to remove translatable text: variable
names are not expected to be translated, so it’s fine to have a line
with `println!("foo: {foo}")` in the code block.

This PR removes 36 messages from the POT file. The number of lines drop
by 633 (3%).

Part of #1257.
This commit is contained in:
Martin Geisler
2023-09-26 17:04:46 +02:00
committed by GitHub
parent a492b2f1b2
commit d0e0e5c1af
27 changed files with 49 additions and 14 deletions

View File

@ -7,6 +7,7 @@
Array assignment and access:
<!-- mdbook-xgettext: skip -->
```rust,editable
fn main() {
let mut a: [i8; 10] = [42; 10];
@ -17,11 +18,12 @@ fn main() {
Tuple assignment and access:
<!-- mdbook-xgettext: skip -->
```rust,editable
fn main() {
let t: (i8, bool) = (7, true);
println!("1st index: {}", t.0);
println!("2nd index: {}", t.1);
println!("t.0: {}", t.0);
println!("t.1: {}", t.1);
}
```

View File

@ -2,6 +2,7 @@
A Rust version of the famous [FizzBuzz](https://en.wikipedia.org/wiki/Fizz_buzz) interview question:
<!-- mdbook-xgettext: skip -->
```rust,editable
fn main() {
print_fizzbuzz_to(20);

View File

@ -2,6 +2,7 @@
Rust will statically forbid dangling references:
<!-- mdbook-xgettext: skip -->
```rust,editable,compile_fail
fn main() {
let ref_x: &i32;

View File

@ -2,6 +2,7 @@
Like C++, Rust has references:
<!-- mdbook-xgettext: skip -->
```rust,editable
fn main() {
let mut x: i32 = 10;

View File

@ -24,6 +24,7 @@ There are a few syntaxes which are not shown above:
== "\\\\n"`. You can embed double-quotes by using an equal amount of `#` on
either side of the quotes:
<!-- mdbook-xgettext: skip -->
```rust,editable
fn main() {
println!(r#"<a href="link.html">link</a>"#);
@ -33,6 +34,7 @@ There are a few syntaxes which are not shown above:
- Byte strings allow you to create a `&[u8]` value directly:
<!-- mdbook-xgettext: skip -->
```rust,editable
fn main() {
println!("{:?}", b"abc");

View File

@ -27,6 +27,7 @@ fn main() {
* Shadowing looks obscure at first, but is convenient for holding on to values after `.unwrap()`.
* The following code demonstrates why the compiler can't simply reuse memory locations when shadowing an immutable variable in a scope, even if the type does not change.
<!-- mdbook-xgettext: skip -->
```rust,editable
fn main() {
let a = 1;

View File

@ -2,6 +2,7 @@
A slice gives you a view into a larger collection:
<!-- mdbook-xgettext: skip -->
```rust,editable
fn main() {
let mut a: [i32; 6] = [10, 20, 30, 40, 50, 60];

View File

@ -8,6 +8,7 @@ cannot be moved or reallocated during the execution of the program.
Constant variables are evaluated at compile time and their values are inlined
wherever they are used:
<!-- mdbook-xgettext: skip -->
```rust,editable
const DIGEST_SIZE: usize = 3;
const ZERO: Option<u8> = Some(42);
@ -22,7 +23,7 @@ fn compute_digest(text: &str) -> [u8; DIGEST_SIZE] {
fn main() {
let digest = compute_digest("Hello");
println!("Digest: {digest:?}");
println!("digest: {digest:?}");
}
```

View File

@ -2,6 +2,7 @@
Rust will look at how the variable is _used_ to determine the type:
<!-- mdbook-xgettext: skip -->
```rust,editable
fn takes_u32(x: u32) {
println!("u32: {x}");
@ -31,6 +32,7 @@ The compiler does the job for us and helps us write more concise code.
The following code tells the compiler to copy into a certain generic container without the code ever explicitly specifying the contained type, using `_` as a placeholder:
<!-- mdbook-xgettext: skip -->
```rust,editable
fn main() {
let mut v = Vec::new();

View File

@ -3,6 +3,7 @@
Rust provides type safety via static typing. Variable bindings are immutable by
default:
<!-- mdbook-xgettext: skip -->
```rust,editable
fn main() {
let x: i32 = 10;