Skip to content

Commit a15432b

Browse files
fix: several typos in the docs (#439)
* fix typo appendix-05-common-types-and-traits-and-cairo-prelude.md * fix typo ch02-05-control-flow.md * fix typo ch03-01-arrays.md * fix typo ch03-03-custom-data-structures.md * fix typo ch07-02-defining-modules-to-control-scope.md * fix typo ch08-00-generic-types-and-traits.md * fix typo ch08-01-generic-data-types.md * fix typo ch08-02-traits-in-cairo.md * fix typo ch10-01-unrecoverable-errors-with-panic.md * fix typo ch11-02-macros.md * Update ch07-02-defining-modules-to-control-scope.md * Update ch07-02-defining-modules-to-control-scope.md
1 parent e18ad31 commit a15432b

9 files changed

+16
-16
lines changed

src/appendix-05-common-types-and-traits-and-cairo-prelude.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ them explicitly into scope.
2525
### List of common types and traits
2626

2727
The following section provides a brief overview of commonly used types and
28-
traits when developping Cairo programs. Most of these are included in the
28+
traits when developing Cairo programs. Most of these are included in the
2929
prelude and not required to be imported explicitly - but not all of them.
3030

3131
| Import | Path | Usage |

src/ch02-05-control-flow.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ Run panicked with err values: [375233589013918064796019]
117117
Remaining gas: 1050
118118
```
119119

120-
> Note: Cairo prevents us from running program with infinite loops by including a gas meter. The gas meter is a mechanism that limits the amount of computation that can be done in a program. By setting a value to the `--available-gas` flag, we can set the maximum amount of gas available to the program. Gas is a unit of measurements that expresses the computation cost of an instruction. When the gas meter runs out, the program will stop. In this case, the program panicked because it ran out of gas, as the stop condition was never reached.
120+
> Note: Cairo prevents us from running program with infinite loops by including a gas meter. The gas meter is a mechanism that limits the amount of computation that can be done in a program. By setting a value to the `--available-gas` flag, we can set the maximum amount of gas available to the program. Gas is a unit of measurement that expresses the computation cost of an instruction. When the gas meter runs out, the program will stop. In this case, the program panicked because it ran out of gas, as the stop condition was never reached.
121121
> It is particularly important in the context of smart contracts deployed on Starknet, as it prevents from running infinite loops on the network.
122122
> If you're writing a program that needs to run a loop, you will need to execute it with the `--available-gas` flag set to a value that is large enough to run the program.
123123

src/ch03-01-arrays.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
An array is a collection of elements of the same type. You can create and use array methods by importing the `array::ArrayTrait` trait.
44

5-
An important thing to note is that arrays have limited modifications options. Arrays are, in fact, queues whose values can't be modified.
5+
An important thing to note is that arrays have limited modification options. Arrays are, in fact, queues whose values can't be modified.
66
This has to do with the fact that once a memory slot is written to, it cannot be overwritten, but only read from it. You can only append items to the end of an array and remove items from the front using `pop_front`.
77

88
### Creating an Array
@@ -13,7 +13,7 @@ Creating an Array is done with the `ArrayTrait::new()` call. Here is an example
1313
{{#include ../listings/ch03-common-collections/no_listing_00_array_new_append/src/lib.cairo}}
1414
```
1515

16-
When required, you can pass the expected type of items inside the array when instantiating the array like this, or explicitly define the type the variable.
16+
When required, you can pass the expected type of items inside the array when instantiating the array like this, or explicitly define the type of the variable.
1717

1818
```rust, noplayground
1919
let mut arr = ArrayTrait::<u128>::new();

src/ch03-03-custom-data-structures.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ level_players.append(10);
1818

1919
But then you realize you can't increase the level at a specific index once it's
2020
set. If a player dies, you cannot remove it from the array unless he happens to
21-
be the in the first position.
21+
be in the first position.
2222

2323
Fortunately, Cairo provides a handy built-in [dictionary
2424
type](./ch03-02-dictionaries.md) called `Felt252Dict<T>` that allows us to
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Generic Types and Traits
22

3-
Every programming language has tools for effectively handling the duplication of concepts. In Cairo, one such tool is generics: abstract stand-ins for concrete types or other properties. We can express the behaviour of generics or how they relate to other generics without knowing what will be in their place when compiling and running the code.
3+
Every programming language has tools for effectively handling the duplication of concepts. In Cairo, one such tool is generics: abstract stand-ins for concrete types or other properties. We can express the behavior of generics or how they relate to other generics without knowing what will be in their place when compiling and running the code.
44

5-
Functions, structs, enums and traits can incorporate generic types as part of their definition instead of a concrete types like `u32` or `ContractAddress`.
5+
Functions, structs, enums and traits can incorporate generic types as part of their definition instead of a concrete type like `u32` or `ContractAddress`.
66

77
Generics allow us to replace specific types with a placeholder that represents multiple types to remove code duplication.
88

99
For each concrete type that replaces a generic type the compiler creates a new definition, reducing development time for the programmer, but code duplication at compile level still exists. This may be of importance if you are writing Starknet contracts and using a generic for multiple types which will cause contract size to increment.
1010

11-
Then you’ll learn how to use traits to define behavior in a generic way. You can combine traits with generic types to constrain a generic type to accept only those types that have a particular behavior, as opposed to just any type.
11+
Then you’ll learn how to use traits to define behavior in a generic way. You can combine traits with generic types to constrain a generic type to accept only those types that have a particular behavior, as opposed to just any type.

src/ch08-01-generic-data-types.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ The new `largest_list` function includes in its definition the requirement that
2020

2121
### Constraints for Generic Types
2222

23-
When defining generic types, it is useful to have information about them. Knowing which traits a generic type implements allow us to use them more effectively in a functions logic at the cost of constraining the generic types that can be used with the function. We saw an example of this previously by adding the `TDrop` implementation as part of the generic arguments of `largest_list`. While `TDrop` was added to satisfy the compilers requirements, we can also add constraints to benefit our function logic.
23+
When defining generic types, it is useful to have information about them. Knowing which traits a generic type implements allow us to use them more effectively in a functions logic at the cost of constraining the generic types that can be used with the function. We saw an example of this previously by adding the `TDrop` implementation as part of the generic arguments of `largest_list`. While `TDrop` was added to satisfy the compiler's requirements, we can also add constraints to benefit our function logic.
2424

25-
Imagine that we want, given a list of elements of some generic type `T`, find the smallest element among them. Initially, we know that for an element of type `T` to be comparable, it must implement the `PartialOrd` trait. The resulting function would be:
25+
Imagine that we want, given a list of elements of some generic type `T`, to find the smallest element among them. Initially, we know that for an element of type `T` to be comparable, it must implement the `PartialOrd` trait. The resulting function would be:
2626

2727
```rust
2828
{{#include ../listings/ch08-generic-types-and-traits/no_listing_03_missing_tcopy/src/lib.cairo}}

src/ch08-02-traits-in-cairo.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ In the code above, `RectangleGeometry` implements the trait `ShapeGeometry` defi
2626

2727
## Implementing a trait, without writing its declaration.
2828

29-
You can write implementations directly without definining the corresponding trait. This is made possible by using the `#[generate_trait]` attribute with on the implementation, which will make the compiler generate the trait corresponding to the implementation automatically. Remember to add `Trait` as a suffix to your trait name, as the compiler will create the trait by adding a `Trait` suffix to the implementation name.
29+
You can write implementations directly without defining the corresponding trait. This is made possible by using the `#[generate_trait]` attribute within the implementation, which will make the compiler generate the trait corresponding to the implementation automatically. Remember to add `Trait` as a suffix to your trait name, as the compiler will create the trait by adding a `Trait` suffix to the implementation name.
3030

3131
```rust,noplayground
3232
{{#include ../listings/ch08-generic-types-and-traits/no_listing_15_generate_trait/src/lib.cairo}}
@@ -63,7 +63,7 @@ To use traits methods, you need to make sure the correct traits/implementation(s
6363
In some cases you might need to import not only the trait but also the implementation if they are declared in separate modules.
6464
If `CircleGeometry` was in a separate module/file `circle` then to use `boundary` on `circ: Circle`, we'd need to import `CircleGeometry` in addition to `ShapeGeometry`.
6565

66-
If the code was organised into modules like this, where the implementation of a trait was defined in a different module than the trait itself, explicitly importing the relevant implementation is required.
66+
If the code was organized into modules like this, where the implementation of a trait was defined in a different module than the trait itself, explicitly importing the relevant implementation is required.
6767

6868
```rust,noplayground
6969
use debug::PrintTrait;

src/ch10-01-unrecoverable-errors-with-panic.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
In Cairo, unexpected issues may arise during program execution, resulting in runtime errors. While the panic function from the core library doesn't provide a resolution for these errors, it does acknowledge their occurrence and terminates the program. There are two primary ways that a panic can be triggered in Cairo: inadvertently, through actions causing the code to panic (e.g., accessing an array beyond its bounds), or deliberately, by invoking the panic function.
44

5-
When a panic occurs, it leads to an abrupt termination of the program. The `panic` function takes an array as argument, which can be used to provide an error message and performs an unwind process where all variables are dropped and dictionaries squashed to ensure the soundness of the program to safely terminate the execution.
5+
When a panic occurs, it leads to an abrupt termination of the program. The `panic` function takes an array as an argument, which can be used to provide an error message and performs an unwind process where all variables are dropped and dictionaries squashed to ensure the soundness of the program to safely terminate the execution.
66

77
Here is how we can `panic` from inside a program and return the error code `2`:
88

@@ -21,7 +21,7 @@ Run panicked with [2 (''), ].
2121

2222
As you can notice in the output, the print statement is never reached, as the program terminates after encountering the `panic` statement.
2323

24-
An alternative and more idiomatic approach to panic in Cairo would be to use the `panic_with_felt252` function. This function serves as an abstraction of the array-defining process and is often preferred due to its clearer and more concise expression of intent. By using `panic_with_felt252`, developers can panic in a one-liner by providing a felt252 error message as argument, making the code more readable and maintainable.
24+
An alternative and more idiomatic approach to panic in Cairo would be to use the `panic_with_felt252` function. This function serves as an abstraction of the array-defining process and is often preferred due to its clearer and more concise expression of intent. By using `panic_with_felt252`, developers can panic in a one-liner by providing a felt252 error message as an argument, making the code more readable and maintainable.
2525

2626
Let's consider an example:
2727

src/ch11-02-macros.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ With `array!`:
2121

2222
### `consteval_int!`
2323

24-
In some situtations, a developer might need to declare a constant that is the result of a computation of integers. To compute a constant expression and use its result at compile time, it is required to use the `consteval_int!` macro.
24+
In some situations, a developer might need to declare a constant that is the result of a computation of integers. To compute a constant expression and use its result at compile time, it is required to use the `consteval_int!` macro.
2525

2626
Here is an example of `consteval_int!`:
2727

2828
```rust
2929
const a: felt252 = consteval_int!(2 * 2 * 2);
3030
```
3131

32-
This will be interprated as `const a: felt252 = 8;` by the compiler.
32+
This will be interpreted as `const a: felt252 = 8;` by the compiler.

0 commit comments

Comments
 (0)