MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / match_directive

Function match_directive

cranelift/filetests/src/match_directive.rs:7–14  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

5///
6/// Return the comment text following the directive.
7pub 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]
17fn test_match_directive() {

Callers 2

runMethod · 0.85
runMethod · 0.85

Calls 1

mapMethod · 0.45

Tested by 2

runMethod · 0.68
runMethod · 0.68