View difference between Paste ID: QgU80wU7 and BgQH2bRz
SHOW: | | - or go back to the newest paste.
1
##################################################################
2
# Working with a warning
3
##################################################################
4
pub fn get_recipes() -> Vec<Recipe> {
5
    use self::schema::recipes::dsl::*;
6
7
    let connection = establish_connection();
8
9
    return recipes
10
        .load::<Recipe>(&connection)
11
        .expect("Error loading recipes");
12
}
13
14
yield =>
15
16
unneeded `return` statement
17
note: `#[warn(clippy::needless_return)]` on by default
18
help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
19
help: remove `return`: `recipes
20
        .load::<Recipe>(&connection)
21
        .expect("Error loading recipes")`clippy(clippy::needless_return)
22
23
##################################################################
24
# Does not work when trying to remove the return statement
25
##################################################################
26
27
pub fn get_recipes() -> Vec<Recipe> {
28
    use self::schema::recipes::dsl::*;
29
30
    let connection = establish_connection();
31
32
    recipes
33
        .load::<Recipe>(&connection)
34
        .expect("Error loading recipes");
35
}
36
37
yield =>
38
39
pub struct Recipe
40
mismatched types
41
42
expected struct `std::vec::Vec`, found `()`
43
note: expected struct `std::vec::Vec<database::models::Recipe>`
44
      found unit type `()`rustc(E0308)
45
mod.rs(19, 8): implicitly returns `()` as its body has no tail or `return` expression
46-
mod.rs(19, 25): expected struct `std::vec::Vec`, found `()`
46+
mod.rs(19, 25): expected struct `std::vec::Vec`, found `()`
47
48
##################################################################
49
# WHERE recipes is defined in my schema.rs diesel file as:
50
##################################################################
51
52
table! {
53
    recipes (id) {
54
        id -> Integer,
55
        name -> Text,
56
        author -> Text,
57
        image -> Text,
58
        prepTime -> Text,
59
        cookTime -> Text,
60
        totalTime -> Text,
61
        recipeYield -> Text,
62
        description -> Text,
63
        category -> Integer,
64
        jsonLd -> Text,
65
    }
66
}