Skip to content

Commit

Permalink
Fix wasm demo
Browse files Browse the repository at this point in the history
  • Loading branch information
mtoohey31 committed Nov 29, 2022
1 parent 8b2a9f1 commit f1352c8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/wasm/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions examples/wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl textwrap::core::Fragment for CanvasWord<'_> {
}

#[inline]
fn whitespace_width(&self) -> f64 {
fn whitespace_width(&self, _: u8) -> f64 {
self.whitespace_width
}

Expand Down Expand Up @@ -351,7 +351,7 @@ pub fn draw_wrapped_text(
let mut lineno = 0;
for line in text.split('\n') {
let words = word_separator.find_words(line);
let split_words = split_words(words, &word_splitter);
let split_words = split_words(words, &word_splitter, 0);

let canvas_words = split_words
.flat_map(|word| {
Expand All @@ -366,10 +366,10 @@ pub fn draw_wrapped_text(

let line_lengths = [options.width];
let wrapped_words = match options.wrap_algorithm {
WasmWrapAlgorithm::FirstFit => wrap_first_fit(&canvas_words, &line_lengths),
WasmWrapAlgorithm::FirstFit => wrap_first_fit(&canvas_words, &line_lengths, 0),
WasmWrapAlgorithm::OptimalFit => {
let penalties = options.penalties.into();
wrap_optimal_fit(&canvas_words, &line_lengths, &penalties).unwrap()
wrap_optimal_fit(&canvas_words, &line_lengths, 0, &penalties).unwrap()
}
_ => Err("WasmOptions has an invalid wrap_algorithm field")?,
};
Expand Down

0 comments on commit f1352c8

Please sign in to comment.