add docs for law::new_desc
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				CI/CD Pipeline / test (push) Successful in 4m45s
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	CI/CD Pipeline / test (push) Successful in 4m45s
				
			This commit is contained in:
		| @@ -347,7 +347,54 @@ impl Builder { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /// Sets a new description for the last classifier. | ||||
|     /// Sets a new description for the last classifier in the law structure. | ||||
|     /// | ||||
|     /// This method updates the description of the most recently added classifier. It's useful for | ||||
|     /// providing additional context or details about the classifier's role or content within the | ||||
|     /// law's hierarchy. | ||||
|     /// | ||||
|     /// # Parameters | ||||
|     /// | ||||
|     /// - `desc`: A string slice representing the new description to be assigned to the last | ||||
|     /// classifier. The description is trimmed of any leading or trailing whitespace before being | ||||
|     /// set. | ||||
|     /// | ||||
|     /// # Behavior | ||||
|     /// | ||||
|     /// - The method trims the input description. - It then attempts to update the description of | ||||
|     /// the last classifier. If no classifier has been added before this method is called, the | ||||
|     /// function will panic, indicating that setting a description requires a preceding classifier | ||||
|     /// to be in place. | ||||
|     /// | ||||
|     /// # Panics | ||||
|     /// | ||||
|     /// Panics if there is no last classifier available when the method is called. This situation | ||||
|     /// occurs if an attempt is made to set a description of a classifier before any classifier has | ||||
|     /// been added to the structure, highlighting a logical error in the usage sequence. | ||||
|     /// | ||||
|     /// # Examples | ||||
|     /// ``` | ||||
|     /// use risp::{config::Config, law::{Law, Heading}}; | ||||
|     /// use std::path::Path; | ||||
|     /// | ||||
|     /// let (_, mut builder, _) = Config::load(Path::new("data/configs/abgb.toml")).unwrap(); | ||||
|     /// | ||||
|     /// builder.new_header("1. Theil"); | ||||
|     /// builder.new_desc("Description of the first header"); | ||||
|     /// | ||||
|     /// let law: Law = builder.into(); | ||||
|     /// assert_eq!( | ||||
|     ///     law, | ||||
|     ///     Law { | ||||
|     ///         name: "ABGB".into(), | ||||
|     ///         header: vec![Heading { | ||||
|     ///             name: "1. Theil".into(), | ||||
|     ///             desc: Some("Description of the first header".into()), | ||||
|     ///             content: vec![] | ||||
|     ///         }] | ||||
|     ///     } | ||||
|     /// ); | ||||
|     /// ``` | ||||
|     pub fn new_desc(&mut self, desc: &str) { | ||||
|         let desc = desc.trim(); | ||||
|         #[cfg(test)] | ||||
| @@ -356,7 +403,7 @@ impl Builder { | ||||
|         debug!("new_desc={desc}"); | ||||
|         self.last_instance | ||||
|             .clone() | ||||
|             .unwrap() | ||||
|             .expect("We can only set a description, if we already have received a classifier.") | ||||
|             .borrow_mut() | ||||
|             .set_desc(desc); | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user