File: prefix.rs

package info (click to toggle)
rust-rust-embed 8.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,184 kB
  • sloc: javascript: 4; makefile: 2
file content (24 lines) | stat: -rw-r--r-- 448 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use rust_embed::Embed;

#[derive(Embed)]
#[folder = "examples/public/"]
#[prefix = "prefix/"]
struct Asset;

#[test]
fn get_with_prefix() {
  assert!(Asset::get("prefix/index.html").is_some());
}

#[test]
fn get_without_prefix() {
  assert!(Asset::get("index.html").is_none());
}

#[test]
fn iter_values_have_prefix() {
  for file in Asset::iter() {
    assert!(file.starts_with("prefix/"));
    assert!(Asset::get(file.as_ref()).is_some());
  }
}