Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ##################################################################
- # Working with a warning
- ##################################################################
- pub fn get_recipes() -> Vec<Recipe> {
- use self::schema::recipes::dsl::*;
- let connection = establish_connection();
- return recipes
- .load::<Recipe>(&connection)
- .expect("Error loading recipes");
- }
- yield =>
- unneeded `return` statement
- note: `#[warn(clippy::needless_return)]` on by default
- help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
- help: remove `return`: `recipes
- .load::<Recipe>(&connection)
- .expect("Error loading recipes")`clippy(clippy::needless_return)
- ##################################################################
- # Does not work when trying to remove the return statement
- ##################################################################
- pub fn get_recipes() -> Vec<Recipe> {
- use self::schema::recipes::dsl::*;
- let connection = establish_connection();
- recipes
- .load::<Recipe>(&connection)
- .expect("Error loading recipes");
- }
- yield =>
- pub struct Recipe
- mismatched types
- expected struct `std::vec::Vec`, found `()`
- note: expected struct `std::vec::Vec<database::models::Recipe>`
- found unit type `()`rustc(E0308)
- mod.rs(19, 8): implicitly returns `()` as its body has no tail or `return` expression
- mod.rs(19, 25): expected struct `std::vec::Vec`, found `()`
- ##################################################################
- # WHERE recipes is defined in my schema.rs diesel file as:
- ##################################################################
- table! {
- recipes (id) {
- id -> Integer,
- name -> Text,
- author -> Text,
- image -> Text,
- prepTime -> Text,
- cookTime -> Text,
- totalTime -> Text,
- recipeYield -> Text,
- description -> Text,
- category -> Integer,
- jsonLd -> Text,
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement