From 5c8406d6d07537f2829288a47e04aca2d706db3b Mon Sep 17 00:00:00 2001 From: mikysett Date: Mon, 10 Oct 2022 17:03:21 +0100 Subject: [PATCH] docs(how_many_references): improve variables names --- subjects/how_many_references/README.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/subjects/how_many_references/README.md b/subjects/how_many_references/README.md index e800de15a..d1dbd3bdd 100644 --- a/subjects/how_many_references/README.md +++ b/subjects/how_many_references/README.md @@ -4,7 +4,7 @@ Create the following **functions**: -- `add_ele`: which adds an element to the value in the `Node`. +- `add_element`: which adds an element to the list in the `Node`. - `how_many_references`: which returns how many times the value is referenced in the code. - `rm_all_ref`: which accepts an `Rc` and removes all elements from the vector that are equal to that value. This should only happen if the two `Rc`s point to the same allocation. @@ -14,18 +14,18 @@ Create the following **functions**: pub use std::rc::Rc; pub struct Node { - pub value: Vec>, + pub ref_list: Vec>, } impl Node { - pub fn new(value: Vec>) -> Node { - Node { value: value } + pub fn new(ref_list: Vec>) -> Node { + Node { ref_list: ref_list } } - pub fn add_ele(&mut self, v: Rc) {} - pub fn rm_all_ref(&mut self, v: Rc) {} + pub fn add_element(&mut self, element: Rc) {} + pub fn rm_all_ref(&mut self, element: Rc) {} } -pub fn how_many_references(value: &Rc) -> usize {} +pub fn how_many_references(ref_list: &Rc) -> usize {} ``` ### Usage @@ -43,10 +43,10 @@ fn main() { let a1 = Rc::new(String::from("a")); let mut new_node = Node::new(vec![a.clone()]); - new_node.add_ele(b.clone()); - new_node.add_ele(a.clone()); - new_node.add_ele(c.clone()); - new_node.add_ele(a.clone()); + new_node.add_element(b.clone()); + new_node.add_element(a.clone()); + new_node.add_element(c.clone()); + new_node.add_element(a.clone()); println!("a: {:?}", how_many_references(&a)); println!("b: {:?}", how_many_references(&b));