Look for a directive in a comment string. The directive is of the form "foo:" and should follow the leading `;` in the comment: ; dominates: block3 block4 Return the comment text following the directive.
(comment: &'a str, directive: &str)
| 5 | /// |
| 6 | /// Return the comment text following the directive. |
| 7 | pub fn match_directive<'a>(comment: &'a str, directive: &str) -> Option<&'a str> { |
| 8 | assert!( |
| 9 | directive.ends_with(':'), |
| 10 | "Directive must include trailing colon" |
| 11 | ); |
| 12 | let text = comment.trim_start_matches(';').trim_start(); |
| 13 | text.strip_prefix(directive).map(|s| s.trim()) |
| 14 | } |
| 15 | |
| 16 | #[test] |
| 17 | fn test_match_directive() { |