Skip to content

Commit

Permalink
Merge pull request #89 from jugglerchris/issue_88
Browse files Browse the repository at this point in the history
Panic when passed a zero width instead of OOM.
  • Loading branch information
jugglerchris authored Oct 29, 2023
2 parents 0020fd7 + f35c807 commit 16dbb93
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1592,6 +1592,9 @@ pub struct RenderTree(RenderNode);
impl RenderTree {
/// Render this document using the given `decorator` and wrap it to `width` columns.
pub fn render<D: TextDecorator>(self, width: usize, decorator: D) -> RenderedText<D> {
if width == 0 {
panic!("Error: width can not be zero");
}
let builder = SubRenderer::new(width, decorator);
let builder = render_tree_to_string(builder, self.0, &mut Discard {});
RenderedText(builder)
Expand Down

0 comments on commit 16dbb93

Please sign in to comment.