Trait pdf_writer::Finish[][src]

pub trait Finish: Sized {
    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 PdfWriter 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 = writer.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 the writer ...

Provided methods

Does nothing but move self, equivalent to drop.

Implementors