You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Is there a supported Docker image for the target architecture? I noticed when trying to build for a Pi Zero that I couldn't find a Docker image for the `arm-unknown-linux-gnueabihf` target. In my case, someone published their own [Docker image](https://hub.docker.com/r/rustreleaser/cross) which I found from a [GitHub Issue](https://github.com/rust-embedded/cross/issues/261)
109
+
- Is there a supported Docker image for the target architecture? I noticed when trying to build for a Pi Zero that I couldn't find a Docker image for the `arm-unknown-linux-gnueabihf` target. In my case, someone published their own [Docker image](https://hub.docker.com/r/rustreleaser/cross) which I found from a [GitHub Issue](https://github.com/rust-embedded/cross/issues/261)
110
110
111
-
```bash
111
+
```console
112
112
Unable to find image 'japaric/arm-unknown-linux-gnueabihf:latest' locally
Copy file name to clipboardExpand all lines: content/2019-08-28.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -77,7 +77,7 @@ The smallest spa you could start with is a little Wasm app that mutates the DOM
77
77
78
78
In src/lib.rs should look pretty familiar. We're leaning on the [web-sys](https://github.com/rustwasm/wasm-bindgen/tree/master/crates/web-sys) another wasm wg joint. These are autogenerated bindings to all the [web api](https://developer.mozilla.org/en-US/docs/Web/API).
79
79
80
-
```
80
+
```rust
81
81
letwindow=web_sys::window().expect("no global `window` exists");
82
82
letdocument=window.document().expect("should have a document on window");
83
83
letbody=document.body().expect("document should have a body");
@@ -95,7 +95,7 @@ In src/lib.rs should look pretty familiar. We're leaning on the [web-sys](https:
95
95
96
96
Then `wasm-pack` tool which drives Cargo will generate our wasm output.
97
97
98
-
```
98
+
```console
99
99
$ cargo install wasm-pack
100
100
$ wasm-pack build --target web
101
101
$ ls pkg/
@@ -126,7 +126,7 @@ We still need efficient dom updates. Many people are working across many differe
126
126
127
127
Who wants to write Rust though? Cant I have a JSX style html dsl? Yes, I have several to sell you but lets focus on [typed-html](https://github.com/bodil/typed-html)
Copy file name to clipboardExpand all lines: content/2019-10-24.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,7 +101,7 @@ For those not in the know say someone says you need the nightly build of a cargo
101
101
102
102
`cargo new helloworld && cd helloworld`
103
103
104
-
```bash
104
+
```console
105
105
$ cargo asm helloworld::main --rust
106
106
fn main() {
107
107
push rbp
@@ -163,7 +163,7 @@ fn main() { }
163
163
164
164
The compiler makes sure things compile, clippy tries to tell you there might be a better way to do things. You can replace 'check' in your ide with 'clippy' or run it on the command line.
165
165
166
-
```bash
166
+
```console
167
167
$ cargo clippy
168
168
warning: casting u32 to f64 may become silently lossy if you later change the type
169
169
--> src/bin.rs:166:51
@@ -180,7 +180,7 @@ $
180
180
181
181
Note you have it installed on nightly, it can also apply the suggestion automatically.
182
182
183
-
```bash
183
+
```console
184
184
$ cargo +nightly fix -Z unstable-options --clippy
185
185
$ cargo clippy
186
186
Finished dev [unoptimized + debuginfo] target(s) in 0.57s
@@ -227,7 +227,7 @@ let matches = App::new("next-prime")
227
227
228
228
> Statements are instructions that perform some action and do not return a value. Expressions evaluate to a resulting value.
Copy file name to clipboardExpand all lines: content/2020-02-26.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ Topics:
23
23
24
24
I'm working on making an example app for the PyGamer which allows the user to draw numbers and the app infers what number is drawn. I want to use a model that was trained on the [MNIST dataset](http://yann.lecun.com/exdb/mnist/), load it in the app, and use it to run inference. I found a crate called [tch](https://crates.io/crates/tch), which is Rust bindings for the [PyTorch C++ API](https://pytorch.org/cppdocs/). There is some [example code](https://github.com/LaurentMazare/tch-rs/issues/50) in a GitHub Issue for saving / loading models. Now I just need to build it for an embedded system. Is it possible? I can add the `#![no_std]` pragma and it still builds. When I add the `#![no_main]` pragma, the build fails with an error:
Copy file name to clipboardExpand all lines: content/2020-06-24.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@ Andrew presented on Rust's portability by creating a crate for visualizing the M
33
33
34
34
For the Python package, he used [pyo3](https://crates.io/crates/pyo3) to generate a native Python module. He then used the module in a Jupyter notebook simply with:
35
35
36
-
```
36
+
```rust
37
37
frommatplotlibimportpyplotasplt
38
38
frommandelbrot_rsimportgenerate
39
39
@@ -65,7 +65,7 @@ He ended up forking the [oauth2](https://crates.io/crates/oauth2) crate so that
65
65
66
66
Finally, Blaine demonstrated using `field(guard())` macros for locking down mutations:
67
67
68
-
```
68
+
```rust
69
69
pubstructPermissionGuard {
70
70
pubpermission:Permission,
71
71
}
@@ -89,7 +89,7 @@ impl Guard for PermissionGuard {
Copy file name to clipboardExpand all lines: content/2020-08-26.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,28 +35,28 @@ I found that the best place to learn how to use tch to make a linear regression
35
35
36
36
The main challenge I faced in making the example was when I wanted to utilize the linear regression model in the prediction route. The model is created in `main()`:
37
37
38
-
```
38
+
```rust
39
39
letmutvs=nn::VarStore::new(Device::Cpu);
40
40
letlinear=net(&vs.root());
41
41
```
42
42
43
43
The first (naive) approach I attempted was to pass it directly to the prediction route by having Rocket manage it as state:
44
44
45
-
```
45
+
```rust
46
46
rocket::ignite()
47
47
.manage(linear)
48
48
.mount("/", routes![index]).launch();
49
49
```
50
50
51
51
The type of `linear` is [`impl Module`](https://doc.rust-lang.org/edition-guide/rust-2018/trait-system/impl-trait-for-returning-complex-types-with-ease.html#return-position) or "a type that implement nn::Module". Trouble arises when I try to wrap this in State in the definition for the route handler:
`impl Module` cannot be shared between threads safely
61
61
62
62
help: consider further restricting this bound: ` + std::marker::Sync`rustc(E0277)
@@ -67,7 +67,7 @@ state.rs(106, 32): required by this bound in `rocket::State`
67
67
68
68
In this case, the advice for this error is not particularly helpful because further restricting the bounds only changes the error:
69
69
70
-
```
70
+
```console
71
71
the size for values of type `(dyn tch::nn::Module + std::marker::Sync + 'static)` cannot be known at compilation time
72
72
73
73
doesn't have a size known at compile-time
@@ -77,15 +77,15 @@ help: the trait `std::marker::Sized` is not implemented for `(dyn tch::nn::Modul
77
77
78
78
The solution I found was to use a [mutex](https://doc.rust-lang.org/std/sync/struct.Mutex.html) to ensure that shared access to the model in the route and main thread is protected. The `main()` function becomes:
0 commit comments