#assets #loading #macro #run-time #include-str #include-bytes #content

load_file

Macros to help conveniently load the contents of files during development

6 releases (2 stable)

Uses old Rust 2015

1.0.1 Jul 30, 2021
1.0.0 Aug 14, 2018
0.1.3 Aug 10, 2018

#1777 in Development tools

Download history 1884/week @ 2024-11-16 292/week @ 2024-11-23 933/week @ 2024-11-30 5467/week @ 2024-12-07 2614/week @ 2024-12-14 352/week @ 2024-12-21 518/week @ 2024-12-28 1931/week @ 2025-01-04 1058/week @ 2025-01-11 1851/week @ 2025-01-18 1448/week @ 2025-01-25 1036/week @ 2025-02-01 1163/week @ 2025-02-08 1537/week @ 2025-02-15 1566/week @ 2025-02-22 1390/week @ 2025-03-01

5,894 downloads per month
Used in 2 crates

MIT license

9KB
82 lines

Build Status Latest version Documentation

This crate provides macros to help conveniently load the contents of files during development.

load_str! and load_bytes! are modeled after include_str! and include_bytes! from the standard library. The standard library macros are useful in many situations, one of which is quick-and-dirty loading of assets during a prototyping phase. (Examples of such assets are static web assets such as CSS or GLSL shaders for a game.) The load_* macros aim to offer a convenient way of loading the assets dynamically at run-time instead. This gets rid of the need to compile or even restart for every change while iterating on the assets.

Example

Before:

fn main() {
    println!("{}", include_str!("greeting.txt"));
}

After:

#[macro_use]
extern crate load_file;

fn main() {
    println!("{}", load_str!("greeting.txt"));
}

No runtime deps