Skip to content

Commit 1639775

Browse files
committed
feat: update module2 challenge
1 parent b1c3299 commit 1639775

File tree

26 files changed

+80
-677
lines changed

26 files changed

+80
-677
lines changed

.github/workflows/rust.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ jobs:
1717
matrix:
1818
project:
1919
- "src/examples/module1/rust_app"
20-
- "src/examples/module2/1-memory-safety/rust_app_memory_demo"
21-
- "src/examples/module2/2-sustainability/rust_app"
20+
- "src/demos/1-memory-safety/rust_app_memory_demo"
21+
- "src/demos/2-sustainability/rust_app"
2222
- "src/examples/module4/rust_app"
2323
- "src/examples/module5/rust_app"
2424
- "src/examples/module6/rust_app"
@@ -27,8 +27,9 @@ jobs:
2727
- "src/examples/module9/rust_app"
2828
- "src/examples/module10/rust_app"
2929
- "src/solutions/module1/rust_app"
30-
- "src/solutions/module2/1-memory-safety/rust_app_memory_demo"
31-
- "src/solutions/module2/2-sustainability/rust_app"
30+
- "src/demos/1-memory-safety/rust_app_memory_demo"
31+
- "src/demos/2-sustainability/rust_app"
32+
- "src/solutions/module2/rust_app"
3233
- "src/solutions/module3/rust_app"
3334
- "src/solutions/module4/rust_app"
3435
- "src/solutions/module5/rust_app"

docs/docs/module2/6_memory-safety.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ This approach provides:
4040

4141
## Analyzing the Memory Safety Examples
4242

43-
You'll first look at specific examples from the codebase that demonstrate these differences. You can find them in [GitHub](https://github.com/jeastham1993/rust-for-dotnet-devs-workshop/tree/main/src/solutions/module2/1-memory-safety).
43+
You'll first look at specific examples from the codebase that demonstrate these differences. You can find them in [GitHub](https://github.com/jeastham1993/rust-for-dotnet-devs-workshop/tree/main/src/demos/1--memory-safety).
4444

4545
### .NET Example
4646

47-
[.NET Sample Link](https://github.com/jeastham1993/rust-for-dotnet-devs-workshop/blob/main/src/solutions/module2/1-memory-safety/DotnetMemorySafety/Program.cs)
47+
[.NET Sample Link](https://github.com/jeastham1993/rust-for-dotnet-devs-workshop/blob/main/src/demos/1--memory-safety/DotnetMemorySafety/Program.cs)
4848

4949
```csharp showLineNumbers
5050
var user = new User(){
@@ -80,7 +80,7 @@ This C# code creates a `User` object and then attempts to update its name from t
8080

8181
### Rust Example
8282

83-
[Rust Link](https://github.com/jeastham1993/rust-for-dotnet-devs-workshop/blob/main/src/solutions/module2/1-memory-safety/rust_app/src/main.rs)
83+
[Rust Link](https://github.com/jeastham1993/rust-for-dotnet-devs-workshop/blob/main/src/demos/1--memory-safety/rust_app/src/main.rs)
8484

8585
```rust showLineNumbers
8686
#[tokio::main]
@@ -111,7 +111,7 @@ async fn main() {
111111
The Rust example attempts something similar but with a crucial difference: it **will not compile**. You can try if you want:
112112

113113
```sh
114-
cd src/examples/module2/1-memory-safety/rust_app
114+
cd src/demos/1-memory-safety/rust_app
115115
cargo run
116116
```
117117

docs/docs/module2/8_challenge.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ sidebar_position: 8
44

55
# Challenge
66

7-
There is no explicit coding challenge in this example, however, I would recommend exploring the [memory demo](https://github.com/jeastham1993/rust-for-dotnet-devs-workshop/tree/main/src/solutions/module2/1-memory-safety) and [memory efficiency](https://github.com/jeastham1993/rust-for-dotnet-devs-workshop/tree/main/src/solutions/module2/2-sustainability) demos alongside their .NET counterparts.
7+
## Demos
8+
9+
There are a couple of demos as part of this module, however, I would recommend exploring the [memory demo](https://github.com/jeastham1993/rust-for-dotnet-devs-workshop/tree/main/src/demos/1--memory-safety) and [memory efficiency](https://github.com/jeastham1993/rust-for-dotnet-devs-workshop/tree/main/src/solutions/module2/2-sustainability) demos alongside their .NET counterparts.
10+
11+
Open up Activity Monitor on Mac, or Task Manager on Windows, and then run both the .NET and Rust examples and see how it affects your local resource consumption.
12+
13+
## Challenge
14+
15+
The code in [src/examples/module2/rust_app](/src/examples/module2/rust_app/) contains the beginnings of a user management application. But it **doesn't compile** 🥺, your challenge is to get this small code snippet working. There are issues with borrowing, ownership and mutability.
16+
17+
If you get past that, you can also try to better handle errors in the `update_name` function. Instead of always updating the name, let's return an error if the length of the new name is less than or equal to zero.
18+
19+
820

9-
Open up Activity Monitor on Mac, or Task Manager on Windows, and then run both the .NET and Rust examples and see how it affects your local resource consumption.

src/examples/module2/1-memory-safety/DotnetMemorySafety/DotnetMemorySafety.csproj renamed to src/demos/1-memory-safety/DotnetMemorySafety/DotnetMemorySafety.csproj

File renamed without changes.

src/examples/module2/1-memory-safety/DotnetMemorySafety/Program.cs renamed to src/demos/1-memory-safety/DotnetMemorySafety/Program.cs

File renamed without changes.
File renamed without changes.
File renamed without changes.

src/examples/module2/1-memory-safety/rust_app_memory_demo/Cargo.toml renamed to src/demos/1-memory-safety/rust_app_memory_demo/Cargo.toml

File renamed without changes.

src/examples/module2/1-memory-safety/rust_app_memory_demo/src/main.rs renamed to src/demos/1-memory-safety/rust_app_memory_demo/src/main.rs

File renamed without changes.

src/examples/module2/2-sustainability/DotnetConsoleApp/DotnetConsoleApp.csproj renamed to src/demos/2-sustainability/DotnetConsoleApp/DotnetConsoleApp.csproj

File renamed without changes.

0 commit comments

Comments
 (0)