1#[derive(Debug)]
6pub struct Method {
7 pub name: &'static str,
8 pub kind: MethodKind,
9 pub params: &'static [&'static str],
11 pub summary: &'static str,
12}
13
14#[derive(Clone, Copy, Debug, PartialEq, Eq)]
16pub enum MethodKind {
17 Len,
18 IsEmpty,
19 Push,
20 Remove,
21}
22
23pub const METHODS: &[Method] = &[
24 Method {
25 name: "len",
26 kind: MethodKind::Len,
27 params: &[],
28 summary: "How many items a list has, or characters a string has.",
29 },
30 Method {
31 name: "is_empty",
32 kind: MethodKind::IsEmpty,
33 params: &[],
34 summary: "Whether a list or string has nothing in it.",
35 },
36 Method {
37 name: "push",
38 kind: MethodKind::Push,
39 params: &["item"],
40 summary: "Adds an item to the end of a list.",
41 },
42 Method {
43 name: "remove",
44 kind: MethodKind::Remove,
45 params: &["index"],
46 summary: "Removes the item at a position in a list.",
47 },
48];
49
50#[must_use]
52pub fn method(name: &str) -> Option<&'static Method> {
53 METHODS.iter().find(|method| method.name == name)
54}