mirror of
https://git.aramjonghu.dev/AramJonghu/rustlings.git
synced 2026-09-07 18:23:30 +02:00
Compare commits
3
Commits
27abea4b5b
...
1c85acbd7e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c85acbd7e | ||
|
|
d23998f2b3 | ||
|
|
e84e3ac8cc |
@@ -1,56 +0,0 @@
|
|||||||
name: Check
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [main]
|
|
||||||
paths-ignore:
|
|
||||||
- website
|
|
||||||
- .github/workflows/website.yml
|
|
||||||
- '*.md'
|
|
||||||
pull_request:
|
|
||||||
branches: [main]
|
|
||||||
paths-ignore:
|
|
||||||
- website
|
|
||||||
- .github/workflows/website.yml
|
|
||||||
- '*.md'
|
|
||||||
|
|
||||||
env:
|
|
||||||
CARGO_TERM_COLOR: always
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
clippy:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v6
|
|
||||||
- name: Clippy
|
|
||||||
run: cargo clippy -- --deny warnings
|
|
||||||
fmt:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v6
|
|
||||||
- name: rustfmt
|
|
||||||
run: cargo fmt --all --check
|
|
||||||
test:
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v6
|
|
||||||
- uses: swatinem/rust-cache@v2
|
|
||||||
- name: cargo test
|
|
||||||
env:
|
|
||||||
RUST_BACKTRACE: 1
|
|
||||||
run: cargo test --workspace
|
|
||||||
dev-check:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v6
|
|
||||||
- uses: swatinem/rust-cache@v2
|
|
||||||
- name: rustlings dev check
|
|
||||||
run: cargo dev check --require-solutions
|
|
||||||
rumdl:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v6
|
|
||||||
- uses: rvben/rumdl@v0
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
name: Website
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
push:
|
|
||||||
branches: [main]
|
|
||||||
paths:
|
|
||||||
- website
|
|
||||||
- .github/workflows/website.yml
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
rumdl:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v6
|
|
||||||
- uses: rvben/rumdl@v0
|
|
||||||
build:
|
|
||||||
needs: rumdl
|
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
working-directory: website
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v6
|
|
||||||
- name: Install TailwindCSS
|
|
||||||
run: npm install
|
|
||||||
- name: Build CSS
|
|
||||||
run: npx @tailwindcss/cli -m -i input.css -o static/main.css
|
|
||||||
- name: Download Zola
|
|
||||||
run: curl -fsSL https://github.com/getzola/zola/releases/download/v0.22.1/zola-v0.22.1-x86_64-unknown-linux-gnu.tar.gz | tar xz
|
|
||||||
- name: Build site
|
|
||||||
run: ./zola build
|
|
||||||
- name: Upload static files as artifact
|
|
||||||
uses: actions/upload-pages-artifact@v5
|
|
||||||
with:
|
|
||||||
path: website/public/
|
|
||||||
deploy:
|
|
||||||
needs: build
|
|
||||||
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
|
|
||||||
permissions:
|
|
||||||
pages: write # to deploy to Pages
|
|
||||||
id-token: write # to verify the deployment originates from an appropriate source
|
|
||||||
# Deploy to the github-pages environment
|
|
||||||
environment:
|
|
||||||
name: github-pages
|
|
||||||
url: ${{ steps.deployment.outputs.page_url }}
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Deploy to GitHub Pages
|
|
||||||
uses: actions/deploy-pages@v5
|
|
||||||
Generated
+4
@@ -167,6 +167,10 @@ dependencies = [
|
|||||||
"windows-sys 0.61.2",
|
"windows-sys 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "exercises"
|
||||||
|
version = "0.0.0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fastrand"
|
name = "fastrand"
|
||||||
version = "2.4.1"
|
version = "2.4.1"
|
||||||
|
|||||||
+4
-1
@@ -1,7 +1,10 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
|
members = [
|
||||||
|
"rustlings-macros",
|
||||||
|
"dev",
|
||||||
|
]
|
||||||
exclude = [
|
exclude = [
|
||||||
"tests/test_exercises",
|
"tests/test_exercises",
|
||||||
"dev",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ fn is_even(num: i64) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Fix the function signature.
|
// TODO: Fix the function signature.
|
||||||
fn sale_price(price: i64) -> {
|
fn sale_price(price: i64) -> i64 {
|
||||||
if is_even(price) {
|
if is_even(price) {
|
||||||
price - 10
|
price - 10
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// TODO: Fix the function body without changing the signature.
|
// TODO: Fix the function body without changing the signature.
|
||||||
fn square(num: i32) -> i32 {
|
fn square(num: i32) -> i32 {
|
||||||
num * num;
|
num * num
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|||||||
@@ -4,6 +4,11 @@ fn bigger(a: i32, b: i32) -> i32 {
|
|||||||
// Do not use:
|
// Do not use:
|
||||||
// - another function call
|
// - another function call
|
||||||
// - additional variables
|
// - additional variables
|
||||||
|
if a > b {
|
||||||
|
a
|
||||||
|
} else {
|
||||||
|
b
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|||||||
@@ -2,8 +2,10 @@
|
|||||||
fn picky_eater(food: &str) -> &str {
|
fn picky_eater(food: &str) -> &str {
|
||||||
if food == "strawberry" {
|
if food == "strawberry" {
|
||||||
"Yummy!"
|
"Yummy!"
|
||||||
|
} else if food == "potato" {
|
||||||
|
"I guess I can eat that."
|
||||||
} else {
|
} else {
|
||||||
1
|
"No thanks!"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ fn animal_habitat(animal: &str) -> &str {
|
|||||||
let identifier = if animal == "crab" {
|
let identifier = if animal == "crab" {
|
||||||
1
|
1
|
||||||
} else if animal == "gopher" {
|
} else if animal == "gopher" {
|
||||||
2.0
|
2
|
||||||
} else if animal == "snake" {
|
} else if animal == "snake" {
|
||||||
3
|
3
|
||||||
} else {
|
} else {
|
||||||
"Unknown"
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
// Don't change the expression below!
|
// Don't change the expression below!
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ fn main() {
|
|||||||
|
|
||||||
// TODO: Define a boolean variable with the name `is_evening` before the `if` statement below.
|
// TODO: Define a boolean variable with the name `is_evening` before the `if` statement below.
|
||||||
// The value of the variable should be the negation (opposite) of `is_morning`.
|
// The value of the variable should be the negation (opposite) of `is_morning`.
|
||||||
// let …
|
let is_evening = true;
|
||||||
|
|
||||||
if is_evening {
|
if is_evening {
|
||||||
println!("Good evening!");
|
println!("Good evening!");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,18 @@
|
|||||||
// TODO: Write a function that calculates the price of an order of apples given
|
// TODO: Write a function that calculates the price of an order of apples given
|
||||||
// the quantity bought.
|
// the quantity bought.
|
||||||
// fn calculate_price_of_apples(???) -> ??? { ??? }
|
// fn calculate_price_of_apples(???) -> ??? { ??? }
|
||||||
|
fn calculate_price_of_apples(apples: i32) -> i32 {
|
||||||
|
let mut cost: i32 = 2;
|
||||||
|
|
||||||
|
if apples > 40 {
|
||||||
|
cost = 1;
|
||||||
|
cost *= apples;
|
||||||
|
cost
|
||||||
|
} else {
|
||||||
|
cost *= apples;
|
||||||
|
cost
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// You can optionally experiment here.
|
// You can optionally experiment here.
|
||||||
|
|||||||
Reference in New Issue
Block a user