Skip to content

Commit

Permalink
Add doc about possible chunk name prefixes
Browse files Browse the repository at this point in the history
  • Loading branch information
khvzak committed Nov 24, 2024
1 parent fc1c80c commit 9ae3cb0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ use crate::value::Value;
/// [loadable by Lua]: https://www.lua.org/manual/5.4/manual.html#3.3.2
pub trait AsChunk<'a> {
/// Returns optional chunk name
///
/// See [`Chunk::set_name`] for possible name prefixes.
fn name(&self) -> Option<StdString> {
None
}
Expand Down Expand Up @@ -306,6 +308,11 @@ impl Compiler {

impl Chunk<'_> {
/// Sets the name of this chunk, which results in more informative error traces.
///
/// Possible name prefixes:
/// - `@` - file path (when truncation is needed, the end of the file path is kept, as this is
/// more useful for identifying the file)
/// - `=` - custom chunk name (when truncation is needed, the beginning of the name is kept)
pub fn set_name(mut self, name: impl Into<String>) -> Self {
self.name = name.into();
self
Expand Down

0 comments on commit 9ae3cb0

Please sign in to comment.