MCPcopy Index your code
hub / github.com/RustPython/RustPython / func_sig

Function func_sig

crates/derive-impl/src/util.rs:806–838  ·  view source on GitHub ↗
(sig: &Signature)

Source from the content-addressed store, hash-verified

804}
805
806fn func_sig(sig: &Signature) -> String {
807 sig.inputs
808 .iter()
809 .filter_map(|arg| {
810 use syn::FnArg::*;
811 let arg = match arg {
812 Typed(typed) => typed,
813 Receiver(_) => return Some("$self".to_owned()),
814 };
815 let ty = arg.ty.as_ref();
816 let ty = quote!(#ty).to_string();
817 if ty == "FuncArgs" {
818 return Some("*args, **kwargs".to_owned());
819 }
820 if ty.starts_with('&') && ty.ends_with("VirtualMachine") {
821 return None;
822 }
823 let ident = match arg.pat.as_ref() {
824 syn::Pat::Ident(p) => p.ident.to_string(),
825 // FIXME: other => unreachable!("function arg pattern must be ident but found `{}`", quote!(fn #ident(.. #other ..))),
826 other => quote!(#other).to_string(),
827 };
828 if ident == "zelf" {
829 return Some("$self".to_owned());
830 }
831 if ident == "vm" {
832 unreachable!("type &VirtualMachine(`{ty}`) must be filtered already");
833 }
834 Some(ident)
835 })
836 .collect::<Vec<_>>()
837 .join(", ")
838}
839
840pub(crate) fn format_doc(sig: &str, doc: &str) -> String {
841 format!("{sig}\n--\n\n{doc}")

Callers 1

text_signatureFunction · 0.85

Calls 8

to_stringMethod · 0.80
starts_withMethod · 0.80
ends_withMethod · 0.80
SomeClass · 0.50
joinMethod · 0.45
iterMethod · 0.45
to_ownedMethod · 0.45
as_refMethod · 0.45

Tested by

no test coverage detected