Skip to content

Commit

Permalink
style: enable clippy pedantic
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandervantrijffel committed Oct 12, 2024
1 parent 2f69bef commit fedc756
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
#![warn(clippy::all, clippy::pedantic, clippy::nursery, clippy::cargo)]
#![allow(clippy::cargo_common_metadata)]

pub mod mutate_in_closure;
pub mod vec_any;
4 changes: 3 additions & 1 deletion src/mutate_in_closure.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use std::cell::RefCell;

// Use RefCell to mutate a variable in a closure
/// Use ``RefCell`` to mutate a variable in a closure
/// # Panics
///
pub fn mutate_in_closure() {
let my_string = RefCell::new("hello".to_string());
let mutate = |new_val| {
Expand Down
6 changes: 4 additions & 2 deletions src/vec_any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ trait AnyAnimal: Animal + AsAny {}
impl<T: Animal + AsAny> AnyAnimal for T {}
type BoxedAnimal = Box<dyn AnyAnimal>;

// Demonstrates creating a vector of common Animal trait objects,
// then downcasting to a concrete Dog type instance to be able to access its fields.
/// Demonstrates creating a vector of common Animal trait objects,
/// then downcasting to a concrete Dog type instance to be able to access its fields.
/// # Panics
///
pub fn downcast_concrete_type_instance_from_trait_object() {
let c = Cat {};
let d = Dog { name: "Fido".to_string() };
Expand Down

0 comments on commit fedc756

Please sign in to comment.