Skip to content

Commit

Permalink
Update hints headings
Browse files Browse the repository at this point in the history
  • Loading branch information
0xNeshi committed Dec 22, 2024
1 parent faba00f commit 38f76df
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
4 changes: 4 additions & 0 deletions concepts/printing/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ println!("Values: x = {}, y = {}", x, y);
```

In the above example:

- `{}` placeholders are replaced by the values of `x` and `y`.
- `println!` ensures the output ends with a new line.

Expand All @@ -47,6 +48,7 @@ println!("{}", result); // Output: tic-tac-toe
```

In this example:

- `format!` combines `s1`, `s2`, and `s3` into a single string, separating them with dashes (`-`).
- The resulting string can be reused or printed later.

Expand Down Expand Up @@ -81,6 +83,7 @@ println!("{}", p); // Output: Point(3, 4)
```

In this example:

- The `fmt` function defines how the `Point` struct is converted to a printable string.
- The `write!` macro appends the formatted string to the `Formatter`.

Expand All @@ -102,6 +105,7 @@ println!("{:?}", p); // Output: Point { x: 3, y: 4 }
```

In this example:

- `#[derive(Debug)]` automatically generates the implementation for the `Debug` trait.
- The `{:?}` placeholder tells `println!` to use the `Debug` trait for formatting.

Expand Down
5 changes: 3 additions & 2 deletions concepts/printing/introduction.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Introduction

Printing in Cairo allows you to display messages, debug information, or formatted values during program execution.
With versatile macros like println! and format!, you can output basic data types, custom formats, or even complex structures.
This makes it easy to inspect and communicate program behavior effectively.
With versatile macros like println!
and format!, you can output basic data types, custom formats, or even complex structures.
This makes it easy to inspect and communicate program behavior effectively.
12 changes: 6 additions & 6 deletions exercises/concept/the-realm-of-echoes/.docs/hints.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
### Hints
# Hints

#### General
# General

- [The Cairo Book: ByteArrays][book-bytearrays]
- [Starknet By Example: Strings & ByteArrays][sbe-strings]

#### 1. Format a magical chant
### 1. Format a magical chant

- Use the `format!` macro to combine multiple `ByteArray` inputs into a single string.
- Separate the chants with a delimiter such as `"-"` to match the expected output.
- Ensure the output is returned as a `ByteArray`.

#### 2. Implement a `Display` trait for `EchoStone`
### 2. Implement a `Display` trait for `EchoStone`

- The `Display` trait allows you to define how the `EchoStone` should appear when printed with `{}`.
- Use the `write!` macro within the `fmt` function to format the output string.
- Include both `power` and `duration` fields in a clear and concise format, e.g., `EchoStone [power: X, duration: Y]`.

#### 3. Implement a `Debug` trait for `EchoStone`
### 3. Implement a `Debug` trait for `EchoStone`

- The `Debug` trait is used for debugging purposes, allowing for more detailed or structured output when printed with `{:?}`.
- Follow a clear debugging format, such as `Debugging EchoStone: { power: X, duration: Y }`.
- Use the `write!` macro to create the debug output.

[book-bytearrays]: https://book.cairo-lang.org/ch02-02-data-types.html#string-types
[sbe-strings]: https://starknet-by-example.voyager.online/getting-started/basics/bytearrays-strings
[sbe-strings]: https://starknet-by-example.voyager.online/getting-started/basics/bytearrays-strings

0 comments on commit 38f76df

Please sign in to comment.