DioxusLabs / DioxusLabs/docsite
Rust build error inside function list_dogs from "https://dioxuslabs.com/learn/0.7/tutorial/routing"
- Dominant language
- Rust
- Stars
- 206
- Forks
- 208
- Avg merge
- 1h 11m
- Merged PRs (30d)
- 3
Description
The following code can't pass Rust build,
```
// Query the database and return the last 10 dogs and their url
#[server]
pub async fn list_dogs() -> Result, ServerFnError> {
let dogs = DB.with(|f| {
f.prepare("SELECT id, url FROM dogs ORDER BY id DESC LIMIT 10")
.unwrap()
.query_map([], |row| Ok((row.get(0)?, row.get(1)?)))
.unwrap()
.map(|r| r.unwrap())
.collect()
});
Ok(dogs)
}
```
The error is:
the trait bound `usize: FromSql` is not satisfied
the following other types implement trait `FromSql`:
f32
f64
i16
i32
i64
i8
isize
u16
and 2 others
Fix proposal:
Change usize to isize in function declaration.
```
#[server]
pub async fn list_dogs() -> Result, ServerFnError> {
let dogs = DB.with(|f| {
f.prepare("SELECT id, url FROM dogs ORDER BY id DESC LIMIT 10")
.unwrap()
.query_map([], |row| Ok((row.get(0)?, row.get(1)?)))
.unwrap()
.map(|r| r.unwrap())
.collect()
});
Ok(dogs)
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.