Skip to content

Commit a14987f

Browse files
updated docs
1 parent 1998725 commit a14987f

File tree

2 files changed

+52
-41
lines changed

2 files changed

+52
-41
lines changed

.github/workflows/docs.yml

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,45 @@
1-
name: Deploy Rust docs
1+
name: Docs
22

33
on:
4-
push:
5-
branches: [ main ]
6-
workflow_dispatch:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
78

89
permissions:
9-
contents: read
10-
pages: write
11-
id-token: write
10+
contents: read
11+
pages: write
12+
id-token: write
13+
14+
concurrency:
15+
group: pages
16+
cancel-in-progress: true
1217

1318
jobs:
14-
build-and-deploy:
15-
runs-on: macos-latest
16-
environment:
17-
name: github-pages
18-
url: ${{ steps.deployment.outputs.page_url }}
19-
concurrency:
20-
group: docs-pages
21-
cancel-in-progress: true
22-
steps:
23-
- name: Checkout
24-
uses: actions/checkout@v4
25-
26-
- name: Install Rust
27-
uses: dtolnay/rust-toolchain@stable
28-
29-
- name: Build docs
30-
run: cargo doc --no-deps --workspace
31-
- name: Prepare Pages artifact
32-
run: touch target/doc/.nojekyll
33-
- name: Upload artifact
34-
uses: actions/upload-pages-artifact@v3
35-
with:
36-
path: target/doc
37-
- name: Deploy to GitHub Pages
38-
id: deployment
39-
uses: actions/deploy-pages@v4
19+
build:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Install Rust
26+
uses: dtolnay/rust-toolchain@stable
27+
28+
- name: Build documentation
29+
run: cargo doc --no-deps
30+
31+
- name: Upload documentation
32+
uses: actions/upload-pages-artifact@v3
33+
with:
34+
path: target/doc
35+
36+
deploy:
37+
needs: build
38+
runs-on: ubuntu-latest
39+
environment:
40+
name: github-pages
41+
url: ${{ steps.deploy.outputs.page_url }}
42+
steps:
43+
- name: Deploy to GitHub Pages
44+
id: deploy
45+
uses: actions/deploy-pages@v4

src/lib.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,7 @@ impl Vector3 {
7979
/// Returns `self` unchanged if the magnitude is zero.
8080
pub fn normalized(self) -> Self {
8181
let mag = self.magnitude();
82-
if mag == 0.0 {
83-
self
84-
} else {
85-
self / mag
86-
}
82+
if mag == 0.0 { self } else { self / mag }
8783
}
8884
}
8985

@@ -259,7 +255,10 @@ where
259255
magnetization.push(m);
260256
}
261257

262-
SimulationResult { times, magnetization }
258+
SimulationResult {
259+
times,
260+
magnetization,
261+
}
263262
}
264263

265264
#[cfg(test)]
@@ -303,7 +302,10 @@ mod tests {
303302

304303
for m in result.magnetization {
305304
let norm = m.magnitude();
306-
assert!((norm - 1.0).abs() < 5e-4, "magnetization norm drifted: {norm}");
305+
assert!(
306+
(norm - 1.0).abs() < 5e-4,
307+
"magnetization norm drifted: {norm}"
308+
);
307309
}
308310
}
309311

@@ -319,6 +321,9 @@ mod tests {
319321
});
320322

321323
let final_state = *result.magnetization.last().unwrap();
322-
assert!(final_state.z > 0.99, "spin failed to align with field: {final_state:?}");
324+
assert!(
325+
final_state.z > 0.99,
326+
"spin failed to align with field: {final_state:?}"
327+
);
323328
}
324329
}

0 commit comments

Comments
 (0)