Skip to content

Commit 3f382a3

Browse files
authoredMay 14, 2024··
Merge branch 'main' into main
2 parents e3aabdf + bcba4d4 commit 3f382a3

File tree

4 files changed

+13
-15
lines changed

4 files changed

+13
-15
lines changed
 

‎listings/ch04-understanding-ownership/listing-04-08/src/main.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ fn first_word(s: &String) -> usize {
1414
fn main() {
1515
let mut s = String::from("hello world");
1616

17-
let word = first_word(&s); // word will get the value 5
17+
let word = first_word(&s); // word obtendrá el valor 5
1818

19-
s.clear(); // this empties the String, making it equal to ""
19+
s.clear(); // esto "vacía" el String, dejando s igual a ""
2020

21-
// word still has the value 5 here, but there's no more string that
22-
// we could meaningfully use the value 5 with. word is now totally invalid!
21+
// word aún tiene el valor 5 aquí, pero ya no hay un string para que
22+
// usar el valor 5 tenga sentido, ¡word es totalmente invalida!
2323
}
2424
// ANCHOR_END: here

‎listings/ch04-understanding-ownership/listing-04-09/src/main.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ fn first_word(s: &str) -> &str {
1616
fn main() {
1717
let my_string = String::from("hello world");
1818

19-
// `first_word` works on slices of `String`s, whether partial or whole
19+
// `first_word` funciona con slices de un string, sean parciales o completos.
2020
let word = first_word(&my_string[0..6]);
2121
let word = first_word(&my_string[..]);
22-
// `first_word` also works on references to `String`s, which are equivalent
23-
// to whole slices of `String`s
22+
// `first_word` también funciona con referencias de un string, que son equivalentes
23+
// a un slice completo de un String
2424
let word = first_word(&my_string);
2525

2626
let my_string_literal = "hello world";
2727

28-
// `first_word` works on slices of string literals, whether partial or whole
28+
// `first_word` funciona con slices de string literales, sean parciales o completos
2929
let word = first_word(&my_string_literal[0..6]);
3030
let word = first_word(&my_string_literal[..]);
3131

32-
// Because string literals *are* string slices already,
33-
// this works too, without the slice syntax!
32+
// Por que los strings literales son slices de strings,esto también funciona,
33+
// sin necesidad de usar la sintaxis de slices.
3434
let word = first_word(my_string_literal);
3535
}
3636
// ANCHOR_END: usage

‎src/ch04-02-references-and-borrowing.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ puntero, una referencia garantiza que apunte a un valor válido de un tipo
1111
particular para la vida de esa referencia.
1212

1313
Aquí está cómo definirías y usarías una función `calcular_longitud` que tiene
14-
una referencia a un objeto como parámetro en lugar de tomar la propiedad del
14+
una referencia a un objeto como parámetro en lugar de tomar la propiedad del valor.
1515

1616
<span class="filename">Nombre de archivo: src/main.rs</span>
1717

@@ -49,7 +49,7 @@ La sintaxis `&s1` nos permite crear una referencia que *se refiere* al valor de
4949
descartará cuando la referencia deje de usarse.
5050

5151
Del mismo modo, la firma de la función usa `&` para indicar que el tipo del
52-
parámetro `s` es una referencia. Vamos a agregar algunas anotaciones
52+
parámetro `s` es una referencia. Vamos a agregar algunas anotaciones:
5353

5454
```rust
5555
{{#rustdoc_include ../listings/ch04-understanding-ownership/no-listing-08-reference-with-annotations/src/main.rs:here}}

‎src/ch10-02-traits.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,7 @@ en su parámetro `item`, que es de algún tipo que implementa el trait `Summary`
213213
Para hacer esto, usamos la sintaxis `impl Trait`, como esto:
214214

215215
```rust,ignore
216-
pub fn notify(item: &impl Summary) {
217-
println!("Breaking news! {}", item.summarize());
218-
}
216+
{{#rustdoc_include ../listings/ch10-generic-types-traits-and-lifetimes/no-listing-04-traits-as-parameters/src/lib.rs:here}}
219217
```
220218

221219
En lugar de un tipo concreto para el parámetro `item`, especificamos el

0 commit comments

Comments
 (0)
Please sign in to comment.