| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::asciirust-analyzer cargo std https://github.com/rust-lang/rust/library/std ascii/::AsciiExtrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ascii/AsciiExt#; |
| 2 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/; |
| 3 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/; |
| 4 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#; |
| 5 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#; |
| 6 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#; |
| 7 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#; |
| 8 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#; |
| 9 | |
| 10 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 11 | struct Entryrust-analyzer cargo pocket-resources 0.3.2 Entry# { |
| 12 | pathrust-analyzer cargo pocket-resources 0.3.2 Entry#path.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 13 | struct_namerust-analyzer cargo pocket-resources 0.3.2 Entry#struct_name.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 14 | struct_name_no_extrust-analyzer cargo pocket-resources 0.3.2 Entry#struct_name_no_ext.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 15 | resource_str_namerust-analyzer cargo pocket-resources 0.3.2 Entry#resource_str_name.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 16 | resource_str_name_no_extrust-analyzer cargo pocket-resources 0.3.2 Entry#resource_str_name_no_ext.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 17 | file_pathrust-analyzer cargo pocket-resources 0.3.2 Entry#file_path.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 18 | enum_namerust-analyzer cargo pocket-resources 0.3.2 Entry#enum_name.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 19 | } |
| 20 | |
| 21 | pub fn packagerust-analyzer cargo pocket-resources 0.3.2 package().<'a, I, P1, P2>(files: I) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> |
| 22 | where I: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = &'a (P1, P2)>, P1: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#> + 'a, P2: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#> + 'a |
| 23 | { |
| 24 | let entries = files.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|&(ref base_dir, ref file)| { |
| 25 | let base_dir = base_dir.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().(); |
| 26 | let file = file.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().(); |
| 27 | |
| 28 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("cargo:rerun-if-changed={}/{}", base_dir.displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().(), file.displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().()); |
| 29 | |
| 30 | Entryrust-analyzer cargo pocket-resources 0.3.2 Entry# { |
| 31 | pathrust-analyzer cargo pocket-resources 0.3.2 Entry#path.: file.parentrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]parent().().into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][IntoIterator]into_iter().().flat_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#flat_map().(|p| p.iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]iter().()).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|val| { |
| 32 | let val = val.to_strrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsStr]to_str().().expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("Cannot process non-UTF8 path"); |
| 33 | val.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|c| c.is_alphanumericrust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]is_alphanumeric().()).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>() |
| 34 | }).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(), |
| 35 | struct_namerust-analyzer cargo pocket-resources 0.3.2 Entry#struct_name.: { |
| 36 | let val = file.file_namerust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]file_name().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 37 | let val = val.to_os_stringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsStr]to_os_string().().into_stringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString]into_string().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 38 | let val = val.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(|c| if c.is_alphanumericrust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]is_alphanumeric().() || c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().'_' { Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(c) } else if c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().'.' { Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#('_') } else { Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# }).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>(); |
| 39 | val.to_ascii_uppercaserust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]to_ascii_uppercase().() |
| 40 | }, |
| 41 | struct_name_no_extrust-analyzer cargo pocket-resources 0.3.2 Entry#struct_name_no_ext.: { |
| 42 | let val = file.file_stemrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]file_stem().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 43 | let val = val.to_os_stringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsStr]to_os_string().().into_stringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString]into_string().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 44 | let val = val.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(|c| if c.is_alphanumericrust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]is_alphanumeric().() || c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().'_' { Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(c) } else if c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().'.' { Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#('_') } else { Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# }).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>(); |
| 45 | val.to_ascii_uppercaserust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]to_ascii_uppercase().() |
| 46 | }, |
| 47 | resource_str_namerust-analyzer cargo pocket-resources 0.3.2 Entry#resource_str_name.: file.displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 48 | resource_str_name_no_extrust-analyzer cargo pocket-resources 0.3.2 Entry#resource_str_name_no_ext.: if file.iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]iter().().countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().1 { |
| 49 | file.file_stemrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]file_stem().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().to_os_stringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsStr]to_os_string().().into_stringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString]into_string().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 50 | } else { |
| 51 | file.parentrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]parent().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add().+rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add()."/" rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().&file.file_stemrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]file_stem().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().to_os_stringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsStr]to_os_string().().into_stringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString]into_string().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 52 | }, |
| 53 | file_pathrust-analyzer cargo pocket-resources 0.3.2 Entry#file_path.: base_dir.joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().(file).displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 54 | enum_namerust-analyzer cargo pocket-resources 0.3.2 Entry#enum_name.: path_to_enum_variantrust-analyzer cargo pocket-resources 0.3.2 path_to_enum_variant().(file), |
| 55 | } |
| 56 | }).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>(); |
| 57 | |
| 58 | let file_path = envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::varrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/var().("OUT_DIR").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 59 | let file_path = Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]new().(&file_path).joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("pocket-resources.rs"); |
| 60 | let mut file = Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#::createrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File]create().(&file_path).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 61 | |
| 62 | tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(file, r#"#[derive(Debug, Clone, Hash, PartialEq, Eq)]"#)); |
| 63 | tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(file, r#"pub enum ResourceId {{"#)); |
| 64 | for entry in &entries { tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(file, r"{},", entry.enum_namerust-analyzer cargo pocket-resources 0.3.2 Entry#enum_name.)); } |
| 65 | tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(file, r#"}}"#)); |
| 66 | |
| 67 | tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(file, r#"impl ResourceId {{"#)); |
| 68 | tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(file, r#" #[inline]"#)); |
| 69 | tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(file, r#" pub fn load(&self) -> &'static [u8] {{"#)); |
| 70 | tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(file, r#" match self {{"#)); |
| 71 | for entry in &entries { |
| 72 | tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(file, r##" |
| 73 | &ResourceId::{} => &include_bytes!(r#"{}/{}"#)[..], |
| 74 | "##, entry.enum_namerust-analyzer cargo pocket-resources 0.3.2 Entry#enum_name., envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::varrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/var().("CARGO_MANIFEST_DIR").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), entry.file_pathrust-analyzer cargo pocket-resources 0.3.2 Entry#file_path.)); |
| 75 | } |
| 76 | tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(file, r#" }}"#)); |
| 77 | tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(file, r#" }}"#)); |
| 78 | tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(file, r#" #[inline]"#)); |
| 79 | tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(file, r#" pub fn name_ext(&self) -> &str {{"#)); |
| 80 | tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(file, r#" match *self {{"#)); |
| 81 | for entry in &entries { |
| 82 | tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(file, r##" |
| 83 | ResourceId::{} => r#"{}"#, |
| 84 | "##, entry.enum_namerust-analyzer cargo pocket-resources 0.3.2 Entry#enum_name., entry.resource_str_namerust-analyzer cargo pocket-resources 0.3.2 Entry#resource_str_name.)); |
| 85 | } |
| 86 | tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(file, r#" }}"#)); |
| 87 | tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(file, r#" }}"#)); |
| 88 | tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(file, r#" #[inline]"#)); |
| 89 | tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(file, r#" pub fn from_name(name: &str) -> Option<ResourceId> {{"#)); |
| 90 | for entry in &entries { |
| 91 | tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(file, r##" |
| 92 | if name == r#"{}"# {{ return Some(ResourceId::{}); }} |
| 93 | "##, entry.resource_str_namerust-analyzer cargo pocket-resources 0.3.2 Entry#resource_str_name., entry.enum_namerust-analyzer cargo pocket-resources 0.3.2 Entry#enum_name.)); |
| 94 | |
| 95 | if entry.resource_str_namerust-analyzer cargo pocket-resources 0.3.2 Entry#resource_str_name. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().entry.resource_str_name_no_extrust-analyzer cargo pocket-resources 0.3.2 Entry#resource_str_name_no_ext. { |
| 96 | if entries.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|e| e.resource_str_name_no_extrust-analyzer cargo pocket-resources 0.3.2 Entry#resource_str_name_no_ext. rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<Self>`]eq().==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<Self>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<Self>`]eq().entry.resource_str_name_no_extrust-analyzer cargo pocket-resources 0.3.2 Entry#resource_str_name_no_ext. || e.resource_str_namerust-analyzer cargo pocket-resources 0.3.2 Entry#resource_str_name. rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<Self>`]eq().==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<Self>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<Self>`]eq().entry.resource_str_name_no_extrust-analyzer cargo pocket-resources 0.3.2 Entry#resource_str_name_no_ext.).countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/filter/impl#[`Filter<I, P>`][Iterator]count().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().1 { |
| 97 | tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(file, r##" |
| 98 | if name == r#"{}"# {{ return Some(ResourceId::{}); }} |
| 99 | "##, entry.resource_str_name_no_extrust-analyzer cargo pocket-resources 0.3.2 Entry#resource_str_name_no_ext., entry.enum_namerust-analyzer cargo pocket-resources 0.3.2 Entry#enum_name.)); |
| 100 | } |
| 101 | } |
| 102 | } |
| 103 | tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(file, r#" None"#)); |
| 104 | tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(file, r#" }}"#)); |
| 105 | tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(file, r#"}}"#)); |
| 106 | |
| 107 | tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writerust-analyzer cargo pocket-resources 0.3.2 write().(&entries, &[], &mut file)); |
| 108 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 109 | } |
| 110 | |
| 111 | fn writerust-analyzer cargo pocket-resources 0.3.2 write().<W>(entries: &[Entryrust-analyzer cargo pocket-resources 0.3.2 Entry#], base: &[Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#], output: &mut W) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> |
| 112 | where W: Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write# |
| 113 | { |
| 114 | let mut sub_paths = HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T>`]new().(); |
| 115 | |
| 116 | for entry in entries { |
| 117 | if entry.pathrust-analyzer cargo pocket-resources 0.3.2 Entry#path..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().base.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() && &entry.pathrust-analyzer cargo pocket-resources 0.3.2 Entry#path.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#base.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().base { |
| 118 | sub_paths.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]insert().(&entry.pathrust-analyzer cargo pocket-resources 0.3.2 Entry#path.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().base.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().); |
| 119 | } |
| 120 | |
| 121 | if entry.pathrust-analyzer cargo pocket-resources 0.3.2 Entry#path. rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/partial_eq/impl#[`Vec<T, A>`][`PartialEq<&[U]>`]ne().!=rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/partial_eq/impl#[`Vec<T, A>`][`PartialEq<&[U]>`]ne(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/partial_eq/impl#[`Vec<T, A>`][`PartialEq<&[U]>`]ne().base { |
| 122 | continue; |
| 123 | } |
| 124 | |
| 125 | tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(output, "#[allow(missing_docs)] pub const {}: ", entry.struct_namerust-analyzer cargo pocket-resources 0.3.2 Entry#struct_name.)); |
| 126 | for _ in 0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range# rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#base.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() { tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(output, r"super::")); } |
| 127 | tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(output, "ResourceId = ")); |
| 128 | for _ in 0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range# rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#base.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() { tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(output, r"super::")); } |
| 129 | tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(output, r"ResourceId::{};", entry.enum_namerust-analyzer cargo pocket-resources 0.3.2 Entry#enum_name.)); |
| 130 | |
| 131 | if entry.struct_namerust-analyzer cargo pocket-resources 0.3.2 Entry#struct_name. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().entry.struct_name_no_extrust-analyzer cargo pocket-resources 0.3.2 Entry#struct_name_no_ext. { |
| 132 | if entries.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|e| e.struct_name_no_extrust-analyzer cargo pocket-resources 0.3.2 Entry#struct_name_no_ext. rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<Self>`]eq().==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<Self>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<Self>`]eq().entry.struct_name_no_extrust-analyzer cargo pocket-resources 0.3.2 Entry#struct_name_no_ext. || e.struct_namerust-analyzer cargo pocket-resources 0.3.2 Entry#struct_name. rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<Self>`]eq().==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<Self>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<Self>`]eq().entry.struct_name_no_extrust-analyzer cargo pocket-resources 0.3.2 Entry#struct_name_no_ext.).countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/filter/impl#[`Filter<I, P>`][Iterator]count().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().1 { |
| 133 | tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(output, "#[allow(missing_docs)] pub const {}: ", entry.struct_name_no_extrust-analyzer cargo pocket-resources 0.3.2 Entry#struct_name_no_ext.)); |
| 134 | for _ in 0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range# rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#base.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() { tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(output, r"super::")); } |
| 135 | tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(output, "ResourceId = ")); |
| 136 | for _ in 0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range# rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#base.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() { tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(output, r"super::")); } |
| 137 | tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(output, r"ResourceId::{};", entry.enum_namerust-analyzer cargo pocket-resources 0.3.2 Entry#enum_name.)); |
| 138 | } |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | for sub_path in sub_paths.iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]iter().() { |
| 143 | tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(output, r#" |
| 144 | #[allow(missing_docs)] |
| 145 | pub mod {} {{ |
| 146 | "#, sub_path)); |
| 147 | |
| 148 | let mut base = base.to_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]to_vec().(); |
| 149 | base.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(sub_path.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()); |
| 150 | tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writerust-analyzer cargo pocket-resources 0.3.2 write().(entries, &base, output)); |
| 151 | |
| 152 | tryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/`r#try`!!(writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(output, r#" |
| 153 | }} |
| 154 | "#)); |
| 155 | } |
| 156 | |
| 157 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 158 | } |
| 159 | |
| 160 | /// Turns a path into a variant name for the enumeration of resources. |
| 161 | fn path_to_enum_variantrust-analyzer cargo pocket-resources 0.3.2 path_to_enum_variant().<P>(path: P) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# where P: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#> { |
| 162 | let path = path.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().(); |
| 163 | |
| 164 | let components = path.iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]iter().() |
| 165 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|val| { |
| 166 | let val = val.to_strrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsStr]to_str().().expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("Cannot process non-UTF8 path"); |
| 167 | let val = val.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|c| c.is_alphanumericrust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]is_alphanumeric().()).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>(); |
| 168 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}{}", val[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index()...1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index()..to_ascii_uppercaserust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]to_ascii_uppercase().(), val[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index().1..]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index()..to_ascii_lowercaserust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]to_ascii_lowercase().()) |
| 169 | }).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>(); |
| 170 | |
| 171 | components.concatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]concat().() |
| 172 | } |