Skip to content

Commit

Permalink
fix: cairo cheatsheet in sub listing
Browse files Browse the repository at this point in the history
  • Loading branch information
julio4 committed Jan 28, 2025
1 parent ac41ee5 commit b78c30c
Show file tree
Hide file tree
Showing 32 changed files with 16 additions and 20 deletions.
4 changes: 0 additions & 4 deletions Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ dependencies = [
"snforge_std",
]

[[package]]
name = "cairo_cheatsheet"
version = "0.1.0"

[[package]]
name = "calling_other_contracts"
version = "0.1.0"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion pages/cairo_cheatsheet/arrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ trait ArrayTrait<T> {
For example:

```cairo
// [!include ~/listings/cairo_cheatsheet/src/array_example.cairo]
// [!include ~/listings/cairo_cheatsheet/listing/src/array_example.cairo]
```
2 changes: 1 addition & 1 deletion pages/cairo_cheatsheet/dict.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ A dictionary is a data structure used to store key-value pairs, enabling efficie
For example:

```cairo
// [!include ~/listings/cairo_cheatsheet/src/dict_example.cairo:sheet]
// [!include ~/listings/cairo_cheatsheet/listing/src/dict_example.cairo:sheet]
```
4 changes: 2 additions & 2 deletions pages/cairo_cheatsheet/enums.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Just like other programming languages, enums (enumerations) are used in cairo to
In cairo, `enum variants` can hold different data types (the unit type, structs, other enums, tuples, default core library types, arrays, dictionaries, ...), as shown in the code snippet below. Furthermore, as a quick reminder, enums are expressions, meaning they can return values.

```cairo
// [!include ~/listings/cairo_cheatsheet/src/enum_example.cairo:enums]
// [!include ~/listings/cairo_cheatsheet/listing/src/enum_example.cairo:enums]
```

Enums can be declared both inside and outside a contract. If declared outside, they need to be imported inside using the `use` keyword, just like other imports.
Expand All @@ -24,5 +24,5 @@ Enums can be declared both inside and outside a contract. If declared outside, t
Here is an example of a contract illustrating the above statements :

```cairo
// [!include ~/listings/cairo_cheatsheet/src/enum_example.cairo:enum_contract]
// [!include ~/listings/cairo_cheatsheet/listing/src/enum_example.cairo:enum_contract]
```
4 changes: 2 additions & 2 deletions pages/cairo_cheatsheet/felt.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Felt

`felt252` is a fundamental data type in Cairo from which all other data types are derived.
`felt252` can also be used to store [short string representations](/getting-started/basics/bytearrays-strings#short-strings) with a maximum length of 31 characters.
`felt252` can also be used to store 'short string representations' with a maximum length of 31 characters.

For example:

```cairo
// [!include ~/listings/cairo_cheatsheet/src/felt_example.cairo:sheet]
// [!include ~/listings/cairo_cheatsheet/listing/src/felt_example.cairo:sheet]
```
2 changes: 1 addition & 1 deletion pages/cairo_cheatsheet/if_let.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
A `if let` statement is a combination of an `if` statement and a `let` statement. It allows you to execute the block only if the pattern matches. It's a cleaner way to handle a `match` statement with only one pattern that you want to handle.

```cairo
// [!include ~/listings/cairo_cheatsheet/src/if_let_example.cairo:sheet]
// [!include ~/listings/cairo_cheatsheet/listing/src/if_let_example.cairo:sheet]
```

### See also
Expand Down
2 changes: 1 addition & 1 deletion pages/cairo_cheatsheet/loop.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ A `loop` specifies a block of code that will run repetitively until a halting co
For example:

```cairo
// [!include ~/listings/cairo_cheatsheet/src/loop_example.cairo:sheet]
// [!include ~/listings/cairo_cheatsheet/listing/src/loop_example.cairo:sheet]
```

### See also
Expand Down
2 changes: 1 addition & 1 deletion pages/cairo_cheatsheet/mapping.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
The `Map` type can be used to represent a collection of key-value.

```cairo
// [!include ~/listings/cairo_cheatsheet/src/mapping_example.cairo]
// [!include ~/listings/cairo_cheatsheet/listing/src/mapping_example.cairo]
```
2 changes: 1 addition & 1 deletion pages/cairo_cheatsheet/match.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ The `match` expression in Cairo allows us to control the flow of our code by com
For example:

```cairo
// [!include ~/listings/cairo_cheatsheet/src/match_example.cairo]
// [!include ~/listings/cairo_cheatsheet/listing/src/match_example.cairo]
```
2 changes: 1 addition & 1 deletion pages/cairo_cheatsheet/struct.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ A struct is a data type similar to a tuple. Like tuples, they can be used to hol
For example:

```cairo
// [!include ~/listings/cairo_cheatsheet/src/struct_example.cairo]
// [!include ~/listings/cairo_cheatsheet/listing/src/struct_example.cairo]
```
2 changes: 1 addition & 1 deletion pages/cairo_cheatsheet/tuples.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ Tuples is a data type to group a fixed number of items of potentially different
For example:

```cairo
// [!include ~/listings/cairo_cheatsheet/src/tuple_example.cairo:sheet]
// [!include ~/listings/cairo_cheatsheet/listing/src/tuple_example.cairo:sheet]
```
2 changes: 1 addition & 1 deletion pages/cairo_cheatsheet/type_casting.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ The `into` method is used for conversion from a smaller data type to a larger da
For example:

```cairo
// [!include ~/listings/cairo_cheatsheet/src/type_casting_example.cairo:sheet]
// [!include ~/listings/cairo_cheatsheet/listing/src/type_casting_example.cairo:sheet]
```
2 changes: 1 addition & 1 deletion pages/cairo_cheatsheet/while.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
A `while` loop allows you to specify a condition that must be true for the loop to continue.

```cairo
// [!include ~/listings/cairo_cheatsheet/src/while_example.cairo:sheet]
// [!include ~/listings/cairo_cheatsheet/listing/src/while_example.cairo:sheet]
```

### See also
Expand Down
2 changes: 1 addition & 1 deletion pages/cairo_cheatsheet/while_let.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
A `while let` loop is a combination of a `while` loop and a `let` statement. It allows you to execute the loop body only if the pattern matches.

```cairo
// [!include ~/listings/cairo_cheatsheet/src/while_let_example.cairo:sheet]
// [!include ~/listings/cairo_cheatsheet/listing/src/while_let_example.cairo:sheet]
```

### See also
Expand Down
2 changes: 1 addition & 1 deletion pages/getting-started/testing/contract-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ To make testing more convenient, the `testing` module of the corelib provides so
- `pop_log<T, +starknet::Event<T>>(address: ContractAddress) -> Option<T>`
- `pop_l2_to_l1_message(address: ContractAddress) -> Option<(felt252, Span<felt252>)>`

You may also need the `info` module from the corelib, which allows you to access information about the current execution context (see [syscalls](/getting-started/basics/syscalls)):
You may also need the `info` module from the corelib, which allows you to access information about the current execution context (see [syscalls](/getting-started/syscalls)):

- `get_caller_address() -> ContractAddress`
- `get_contract_address() -> ContractAddress`
Expand Down

0 comments on commit b78c30c

Please sign in to comment.