Skip to content

Commit

Permalink
Panic when passed a zero width instead of OOM.
Browse files Browse the repository at this point in the history
Fixes #88.
  • Loading branch information
jugglerchris committed Oct 29, 2023
1 parent 0020fd7 commit f35c807
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 f35c807

Please sign in to comment.