Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spans (es) + fixed weight #74

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion content/en/examples/spans.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "spans"
date: 2023-06-21T11:05:00-03:00
weight: 245
draft: false
---

Expand Down
33 changes: 33 additions & 0 deletions content/es/examples/spans.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: "Spans"
weight: 245
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
weight: 245
weight: 350

draft: false
---

La estructura `Span` es una instantánea (o snapshot) de un `arreglo`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
La estructura `Span` es una instantánea (o snapshot) de un `arreglo`
La estructura `Span` es una "captura instantánea" (o snapshot) de un `arreglo`

Todos los métodos para arreglos pueden usarse para esta estructura, con la excepción del método `append()`.

Para crear el `Span` de un `arreglo`, use el método `span()`.

Modificación del ejemplo [snapshots](./snapshots.md):

```rust {.codebox}
use array::ArrayTrait;
use array::SpanTrait;

// Recibe un spam
MarPinPar marked this conversation as resolved.
Show resolved Hide resolved
fn sum_starting_two(dato: Span<u32>) -> u32 {
// data.append(5_u32); <- Esto falla!
MarPinPar marked this conversation as resolved.
Show resolved Hide resolved
*dato[0] + *dato[1]
}

fn main() -> u32 {
let mut dato: Array<u32> = ArrayTrait::new();
dato.append(1_u32);
dato.append(2_u32);
dato.append(3_u32);
dato.append(4_u32);
dato.get(0);
sum_starting_two(dato.span()) // Usando el spam
MarPinPar marked this conversation as resolved.
Show resolved Hide resolved
}
```