MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / r#match

Function r#match

std/re/src/lib.rs:164–185  ·  view source on GitHub ↗
(argv: *const u32, argc: u32, out: *mut u32)

Source from the content-addressed store, hash-verified

162 #[unsafe(no_mangle)]
163 #[allow(clippy::not_unsafe_ptr_arg_deref)]
164 pub extern "C" fn r#match(argv: *const u32, argc: u32, out: *mut u32) -> i32 {
165 if argc != 3 {
166 __internals::stash_error(Error::Type(alloc::format!("match expects 2 positional args, got {}", argc - 1)));
167 return 1;
168 }
169 let pattern = match String::from_handle(unsafe { *argv.add(0) }) {
170 Ok(v) => v,
171 Err(e) => { __internals::stash_error(e); return 1; }
172 };
173 let string = match String::from_handle(unsafe { *argv.add(1) }) {
174 Ok(v) => v,
175 Err(e) => { __internals::stash_error(e); return 1; }
176 };
177 let value = match main::find(&pattern, &string, Mode::Match) {
178 Ok(v) => v.map(|f| f.text),
179 Err(e) => { __internals::stash_error(to_error(e)); return 1; }
180 };
181 match IntoValue::into_handle(value) {
182 Ok(h) => { unsafe { *out = h.into_raw(); } 0 }
183 Err(e) => { __internals::stash_error(e); 1 }
184 }
185 }
186}

Callers

nothing calls this directly

Calls 5

to_errorFunction · 0.85
addMethod · 0.80
into_rawMethod · 0.80
stash_errorFunction · 0.50
findFunction · 0.50

Tested by

no test coverage detected