From: Ian Jackson Date: Wed, 2 Feb 2022 17:59:53 +0000 (+0000) Subject: BROKEN X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=c01ca6b188d134e1bb1e11933f91ed72dcb1ff1a;p=rust-experiments.git BROKEN --- diff --git a/src/main.rs b/src/main.rs index a1b0ad0..c9d96b2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,51 +1,18 @@ -#![warn(noop_method_call)] -#![deny(unreachable_pub)] -#![deny(clippy::all)] -#![deny(clippy::await_holding_lock)] -#![deny(clippy::cast_lossless)] -#![deny(clippy::checked_conversions)] -#![warn(clippy::clone_on_ref_ptr)] -#![warn(clippy::cognitive_complexity)] -#![deny(clippy::debug_assert_with_mut_call)] -#![deny(clippy::exhaustive_enums)] -#![deny(clippy::exhaustive_structs)] -#![deny(clippy::expl_impl_clone_on_copy)] -#![deny(clippy::fallible_impl_from)] -#![deny(clippy::implicit_clone)] -#![deny(clippy::large_stack_arrays)] -#![warn(clippy::manual_ok_or)] -#![warn(clippy::needless_borrow)] -#![warn(clippy::needless_pass_by_value)] -#![warn(clippy::option_option)] -#![warn(clippy::rc_buffer)] -#![deny(clippy::ref_option_ref)] -#![warn(clippy::semicolon_if_nothing_returned)] -#![warn(clippy::trait_duplication_in_bounds)] -#![deny(clippy::unnecessary_wraps)] -#![warn(clippy::unseparated_literal_suffix)] -#![deny(clippy::unwrap_used)] - - -/// Internal: traits in common different cell bodies. pub trait Body: Sized { - /// Convert this type into a RelayMsg, wrapped appropriate. - fn into_message(self) -> RelayMsg; - /// Decode a relay cell body from a provided reader. - fn decode_from_reader(r: &mut Reader<'_>) -> Result; - /// Encode the body of this cell into the end of a vec. fn encode_onto(self, w: &mut Vec); } +struct Wombat; - -fn mutate(w: &mut Vec) { - w.push(0); +impl Body for Wombat { + fn encode_onto(self, w: &mut Vec) { + w.push(0); + } } - fn main() { let mut w = vec![42]; - mutate(&mut w); + Wombat.encode_onto(&mut w); println!("{:?}", &w); }