Trait pdf_writer::Finish

source ·
pub trait Finish: Sized {
    // Provided method
    fn finish(self) { ... }
}
Expand description

Finish objects in postfix-style.

In many cases you can use writers in builder-pattern style so that they are automatically dropped at the appropriate time. Sometimes though you need to bind a writer to a variable and still want to regain access to the Pdf in the same scope. In that case, you need to manually invoke the writer’s Drop implementation. You can of course, just write drop(array) to finish your array, but you might find it more aesthetically pleasing to write array.finish(). That’s what this trait is for.

let mut array = pdf.indirect(Ref::new(1)).array();
array.push().dict().pair(Name(b"Key"), Str(b"Value"));
array.item(2);
array.finish(); // instead of drop(array)

// Do more stuff with `pdf` ...

Provided Methods§

source

fn finish(self)

Does nothing but move self, equivalent to drop.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<T> Finish for T