[go: up one dir, main page]

Write16

Trait Write16 

Source
pub trait Write16 {
    // Required method
    fn write_slice(&mut self, s: &[u16]) -> Result;

    // Provided methods
    fn write_char(&mut self, c: char) -> Result { ... }
    fn size_hint(&mut self, upcoming: usize) -> Result { ... }
}
Expand description

A UTF-16 sink analogous to core::fmt::Write.

Required Methods§

Source

fn write_slice(&mut self, s: &[u16]) -> Result

Write a slice containing UTF-16 to the sink.

The implementor of the trait should not validate UTF-16. It’s the responsibility of the caller to pass valid UTF-16.

Provided Methods§

Source

fn write_char(&mut self, c: char) -> Result

Write a Unicode scalar value to the sink.

Source

fn size_hint(&mut self, upcoming: usize) -> Result

A hint that the caller expects to write upcoming UTF-16 code units. The implementation must not assume upcoming to be exact. The caller may write more or fewer code units using write_slice() and write_char(). However, the caller should try to give reasonable estimates if it uses this method.

For Vec and SmallVec, this maps to reserve(). The default implementation does nothing.

Implementors§