Skip to main content

Style

Struct Style 

Source
pub struct Style {
Show 32 fields pub id: String, pub name: String, pub kind: StyleKind, pub based_on: Option<String>, pub bold: bool, pub italic: bool, pub underline: Option<UnderlineStyle>, pub underline_color: Option<String>, pub color: Option<String>, pub font_size: Option<u16>, pub font_family: Option<String>, pub highlight: Option<Highlight>, pub strike: bool, pub vertical_align: Option<VerticalAlign>, pub small_caps: bool, pub all_caps: bool, pub shading_color: Option<String>, pub text_border: bool, pub character_spacing: Option<i16>, pub vertical_position: Option<i16>, pub hidden: bool, pub alignment: Option<Alignment>, pub line_spacing: Option<u32>, pub space_before: Option<u32>, pub space_after: Option<u32>, pub paragraph_shading_color: Option<String>, pub paragraph_border: bool, pub keep_with_next: bool, pub keep_lines_together: bool, pub page_break_before: bool, pub tabs: Vec<TabStop>, pub contextual_spacing: bool,
}
Expand description

A named style declared in word/styles.xml (CT_Style), applied to paragraphs or runs by id (Paragraph.style_id/Run.style_id).

Only the handful of fields covering the common case — a name, an optional base style to inherit from, and the same character/paragraph formatting already modeled on Run/Paragraph — are modeled. CT_Style has many more (next, link, hidden, uiPriority, table-style-specific properties..), out of scope for now; a style marked as the type’s default (CT_Style’s default attribute) isn’t modeled either — Word falls back to its own built-in default when none is declared, which is sufficient for a first version.

Fields§

§id: String

The style’s id (w:styleId), referenced by Paragraph.style_id/ Run.style_id.

§name: String

The style’s human-readable name (w:name), shown in Word’s style picker.

§kind: StyleKind

Whether this is a paragraph or character style (w:type, ST_StyleType — only these two of its four values are modeled; table/numbering styles are out of scope for now).

§based_on: Option<String>

The id of another style this one inherits from (w:basedOn), or None.

§bold: bool

Whether text in this style is bold. Meaningful for both style kinds: a paragraph style’s run formatting is the default for text typed in that paragraph, unless a run/character style overrides it.

§italic: bool

Whether text in this style is italic.

§underline: Option<UnderlineStyle>

This style’s underline style, mirroring Run.underline.

§underline_color: Option<String>

This style’s underline color, mirroring Run.underline_color.

§color: Option<String>

This style’s text color, mirroring Run.color — see that field’s doc comment.

§font_size: Option<u16>

This style’s font size in whole points, mirroring Run.font_size.

§font_family: Option<String>

This style’s font family/typeface, mirroring Run.font_family.

§highlight: Option<Highlight>

This style’s highlight color, mirroring Run.highlight.

§strike: bool

Whether text in this style is struck through, mirroring Run.strike.

§vertical_align: Option<VerticalAlign>

This style’s vertical alignment, mirroring Run.vertical_align.

§small_caps: bool

Whether text in this style is displayed as small caps, mirroring Run.small_caps.

§all_caps: bool

Whether text in this style is displayed as all caps, mirroring Run.all_caps.

§shading_color: Option<String>

This style’s background shading color, mirroring Run.shading_color.

§text_border: bool

Whether text in this style has a border, mirroring Run.text_border.

§character_spacing: Option<i16>

This style’s character spacing adjustment, mirroring Run.character_spacing.

§vertical_position: Option<i16>

This style’s vertical position, mirroring Run.vertical_position.

§hidden: bool

Whether text in this style is hidden, mirroring Run.hidden.

§alignment: Option<Alignment>

The paragraph alignment this style sets. Only meaningful for StyleKind::Paragraph; ignored (not written) for a character style, which has no paragraph-level formatting of its own.

§line_spacing: Option<u32>

This style’s line spacing, mirroring Paragraph.line_spacing. Only meaningful for StyleKind::Paragraph, same restriction as alignment.

§space_before: Option<u32>

This style’s extra space before a paragraph, mirroring Paragraph.space_before. Only meaningful for StyleKind::Paragraph.

§space_after: Option<u32>

This style’s extra space after a paragraph, mirroring Paragraph.space_after. Only meaningful for StyleKind::Paragraph.

§paragraph_shading_color: Option<String>

This style’s paragraph background shading color, mirroring Paragraph.shading_color. Distinct from shading_color above (that one mirrors Run.shading_color, a run-level w:shd inside w:rPr) — this is the paragraph-level w:shd inside w:pPr; a paragraph style can carry both at once (default run shading AND a paragraph background), which is why they need separate fields. Only meaningful for StyleKind::Paragraph.

§paragraph_border: bool

Whether this style draws a border around the paragraph, mirroring Paragraph.border. Distinct from text_border above for the same reason as paragraph_shading_color vs. shading_color — a paragraph-level w:pBdr inside w:pPr, not the run-level w:bdr inside w:rPr. Only meaningful for StyleKind::Paragraph.

§keep_with_next: bool

This style’s keep-with-next setting, mirroring Paragraph.keep_with_next. Only meaningful for StyleKind::Paragraph — commonly set directly on a built-in “Heading” style rather than on every individual heading paragraph.

§keep_lines_together: bool

This style’s keep-lines-together setting, mirroring Paragraph.keep_lines_together. Only meaningful for StyleKind::Paragraph.

§page_break_before: bool

This style’s page-break-before setting, mirroring Paragraph.page_break_before. Only meaningful for StyleKind::Paragraph.

§tabs: Vec<TabStop>

This style’s custom tab stops, mirroring Paragraph.tabs. Only meaningful for StyleKind::Paragraph.

§contextual_spacing: bool

This style’s contextual-spacing setting, mirroring Paragraph.contextual_spacing. Only meaningful for StyleKind::Paragraph — this is exactly the property Word’s own built-in “List Paragraph” style sets, so consecutive list items don’t get extra gaps between them.

Implementations§

Source§

impl Style

Source

pub fn new( id: impl Into<String>, name: impl Into<String>, kind: StyleKind, ) -> Style

Creates a style with the given id, display name and kind, and no formatting.

Examples found in repository?
examples/docx_styles_and_lists.rs (line 16)
13fn main() -> office_toolkit::Result<()> {
14    let path = output_path("docx_styles_and_lists.docx");
15
16    let heading_style = Style::new("Heading1", "Heading 1", StyleKind::Paragraph)
17        .with_bold(true)
18        .with_font_size(32);
19    let emphasis_style = Style::new("StrongEmphasis", "Strong Emphasis", StyleKind::Character)
20        .with_bold(true)
21        .with_color("C00000");
22
23    let bulleted = NumberingDefinition::bullet(1);
24    let numbered = NumberingDefinition::decimal(2);
25    let custom = NumberingDefinition::new(
26        3,
27        vec![
28            ListLevel::new(NumberFormat::UpperRoman, "%1.", 720, 360),
29            ListLevel::new(NumberFormat::LowerLetter, "%2)", 1440, 360),
30        ],
31    );
32
33    let document = Document::new()
34        .with_style(heading_style)
35        .with_style(emphasis_style)
36        .with_numbering_definition(bulleted)
37        .with_numbering_definition(numbered)
38        .with_numbering_definition(custom)
39        .with_paragraph(heading("Named paragraph and character styles", false))
40        .with_paragraph(
41            Paragraph::with_text("This paragraph uses the Heading 1 style.")
42                .with_style_id("Heading1"),
43        )
44        .with_paragraph(
45            Paragraph::new()
46                .with_run(Run::new("Plain text, then "))
47                .with_run(Run::new("some strongly emphasized text").with_style_id("StrongEmphasis"))
48                .with_run(Run::new(", then plain text again.")),
49        )
50        .with_paragraph(heading("Bulleted list", true))
51        .with_paragraph(Paragraph::with_text("First item").with_numbering(1, 0))
52        .with_paragraph(Paragraph::with_text("Second item").with_numbering(1, 0))
53        .with_paragraph(Paragraph::with_text("A sub-item, one level deeper").with_numbering(1, 1))
54        .with_paragraph(heading("Numbered list", true))
55        .with_paragraph(Paragraph::with_text("First step").with_numbering(2, 0))
56        .with_paragraph(Paragraph::with_text("Second step").with_numbering(2, 0))
57        .with_paragraph(
58            Paragraph::with_text("A sub-step, cumulatively numbered").with_numbering(2, 1),
59        )
60        .with_paragraph(heading(
61            "Custom multi-level list (roman numerals, then letters)",
62            true,
63        ))
64        .with_paragraph(Paragraph::with_text("First top-level item").with_numbering(3, 0))
65        .with_paragraph(Paragraph::with_text("A lettered sub-item").with_numbering(3, 1))
66        .with_paragraph(Paragraph::with_text("Second top-level item").with_numbering(3, 0));
67
68    document.save_to_file(&path)?;
69    println!("Wrote {}", path.display());
70    Ok(())
71}
Source

pub fn with_based_on(self, style_id: impl Into<String>) -> Style

Sets the style this one inherits from (by id) and returns it for chaining.

Source

pub fn with_bold(self, bold: bool) -> Style

Sets whether text in this style is bold and returns it for chaining.

Examples found in repository?
examples/docx_styles_and_lists.rs (line 17)
13fn main() -> office_toolkit::Result<()> {
14    let path = output_path("docx_styles_and_lists.docx");
15
16    let heading_style = Style::new("Heading1", "Heading 1", StyleKind::Paragraph)
17        .with_bold(true)
18        .with_font_size(32);
19    let emphasis_style = Style::new("StrongEmphasis", "Strong Emphasis", StyleKind::Character)
20        .with_bold(true)
21        .with_color("C00000");
22
23    let bulleted = NumberingDefinition::bullet(1);
24    let numbered = NumberingDefinition::decimal(2);
25    let custom = NumberingDefinition::new(
26        3,
27        vec![
28            ListLevel::new(NumberFormat::UpperRoman, "%1.", 720, 360),
29            ListLevel::new(NumberFormat::LowerLetter, "%2)", 1440, 360),
30        ],
31    );
32
33    let document = Document::new()
34        .with_style(heading_style)
35        .with_style(emphasis_style)
36        .with_numbering_definition(bulleted)
37        .with_numbering_definition(numbered)
38        .with_numbering_definition(custom)
39        .with_paragraph(heading("Named paragraph and character styles", false))
40        .with_paragraph(
41            Paragraph::with_text("This paragraph uses the Heading 1 style.")
42                .with_style_id("Heading1"),
43        )
44        .with_paragraph(
45            Paragraph::new()
46                .with_run(Run::new("Plain text, then "))
47                .with_run(Run::new("some strongly emphasized text").with_style_id("StrongEmphasis"))
48                .with_run(Run::new(", then plain text again.")),
49        )
50        .with_paragraph(heading("Bulleted list", true))
51        .with_paragraph(Paragraph::with_text("First item").with_numbering(1, 0))
52        .with_paragraph(Paragraph::with_text("Second item").with_numbering(1, 0))
53        .with_paragraph(Paragraph::with_text("A sub-item, one level deeper").with_numbering(1, 1))
54        .with_paragraph(heading("Numbered list", true))
55        .with_paragraph(Paragraph::with_text("First step").with_numbering(2, 0))
56        .with_paragraph(Paragraph::with_text("Second step").with_numbering(2, 0))
57        .with_paragraph(
58            Paragraph::with_text("A sub-step, cumulatively numbered").with_numbering(2, 1),
59        )
60        .with_paragraph(heading(
61            "Custom multi-level list (roman numerals, then letters)",
62            true,
63        ))
64        .with_paragraph(Paragraph::with_text("First top-level item").with_numbering(3, 0))
65        .with_paragraph(Paragraph::with_text("A lettered sub-item").with_numbering(3, 1))
66        .with_paragraph(Paragraph::with_text("Second top-level item").with_numbering(3, 0));
67
68    document.save_to_file(&path)?;
69    println!("Wrote {}", path.display());
70    Ok(())
71}
Source

pub fn with_italic(self, italic: bool) -> Style

Sets whether text in this style is italic and returns it for chaining.

Source

pub fn with_underline(self, underline: UnderlineStyle) -> Style

Sets this style’s underline style and returns it for chaining.

Source

pub fn with_underline_color(self, underline_color: impl Into<String>) -> Style

Sets the color of this style’s underline (a 6-digit RGB hex string, no leading #) and returns it for chaining. Only meaningful once with_underline has also been called.

Source

pub fn with_color(self, color: impl Into<String>) -> Style

Sets this style’s text color (a 6-digit RGB hex string, no leading #) and returns it for chaining.

Examples found in repository?
examples/docx_styles_and_lists.rs (line 21)
13fn main() -> office_toolkit::Result<()> {
14    let path = output_path("docx_styles_and_lists.docx");
15
16    let heading_style = Style::new("Heading1", "Heading 1", StyleKind::Paragraph)
17        .with_bold(true)
18        .with_font_size(32);
19    let emphasis_style = Style::new("StrongEmphasis", "Strong Emphasis", StyleKind::Character)
20        .with_bold(true)
21        .with_color("C00000");
22
23    let bulleted = NumberingDefinition::bullet(1);
24    let numbered = NumberingDefinition::decimal(2);
25    let custom = NumberingDefinition::new(
26        3,
27        vec![
28            ListLevel::new(NumberFormat::UpperRoman, "%1.", 720, 360),
29            ListLevel::new(NumberFormat::LowerLetter, "%2)", 1440, 360),
30        ],
31    );
32
33    let document = Document::new()
34        .with_style(heading_style)
35        .with_style(emphasis_style)
36        .with_numbering_definition(bulleted)
37        .with_numbering_definition(numbered)
38        .with_numbering_definition(custom)
39        .with_paragraph(heading("Named paragraph and character styles", false))
40        .with_paragraph(
41            Paragraph::with_text("This paragraph uses the Heading 1 style.")
42                .with_style_id("Heading1"),
43        )
44        .with_paragraph(
45            Paragraph::new()
46                .with_run(Run::new("Plain text, then "))
47                .with_run(Run::new("some strongly emphasized text").with_style_id("StrongEmphasis"))
48                .with_run(Run::new(", then plain text again.")),
49        )
50        .with_paragraph(heading("Bulleted list", true))
51        .with_paragraph(Paragraph::with_text("First item").with_numbering(1, 0))
52        .with_paragraph(Paragraph::with_text("Second item").with_numbering(1, 0))
53        .with_paragraph(Paragraph::with_text("A sub-item, one level deeper").with_numbering(1, 1))
54        .with_paragraph(heading("Numbered list", true))
55        .with_paragraph(Paragraph::with_text("First step").with_numbering(2, 0))
56        .with_paragraph(Paragraph::with_text("Second step").with_numbering(2, 0))
57        .with_paragraph(
58            Paragraph::with_text("A sub-step, cumulatively numbered").with_numbering(2, 1),
59        )
60        .with_paragraph(heading(
61            "Custom multi-level list (roman numerals, then letters)",
62            true,
63        ))
64        .with_paragraph(Paragraph::with_text("First top-level item").with_numbering(3, 0))
65        .with_paragraph(Paragraph::with_text("A lettered sub-item").with_numbering(3, 1))
66        .with_paragraph(Paragraph::with_text("Second top-level item").with_numbering(3, 0));
67
68    document.save_to_file(&path)?;
69    println!("Wrote {}", path.display());
70    Ok(())
71}
Source

pub fn with_font_size(self, font_size: u16) -> Style

Sets this style’s font size in whole points and returns it for chaining.

Examples found in repository?
examples/docx_styles_and_lists.rs (line 18)
13fn main() -> office_toolkit::Result<()> {
14    let path = output_path("docx_styles_and_lists.docx");
15
16    let heading_style = Style::new("Heading1", "Heading 1", StyleKind::Paragraph)
17        .with_bold(true)
18        .with_font_size(32);
19    let emphasis_style = Style::new("StrongEmphasis", "Strong Emphasis", StyleKind::Character)
20        .with_bold(true)
21        .with_color("C00000");
22
23    let bulleted = NumberingDefinition::bullet(1);
24    let numbered = NumberingDefinition::decimal(2);
25    let custom = NumberingDefinition::new(
26        3,
27        vec![
28            ListLevel::new(NumberFormat::UpperRoman, "%1.", 720, 360),
29            ListLevel::new(NumberFormat::LowerLetter, "%2)", 1440, 360),
30        ],
31    );
32
33    let document = Document::new()
34        .with_style(heading_style)
35        .with_style(emphasis_style)
36        .with_numbering_definition(bulleted)
37        .with_numbering_definition(numbered)
38        .with_numbering_definition(custom)
39        .with_paragraph(heading("Named paragraph and character styles", false))
40        .with_paragraph(
41            Paragraph::with_text("This paragraph uses the Heading 1 style.")
42                .with_style_id("Heading1"),
43        )
44        .with_paragraph(
45            Paragraph::new()
46                .with_run(Run::new("Plain text, then "))
47                .with_run(Run::new("some strongly emphasized text").with_style_id("StrongEmphasis"))
48                .with_run(Run::new(", then plain text again.")),
49        )
50        .with_paragraph(heading("Bulleted list", true))
51        .with_paragraph(Paragraph::with_text("First item").with_numbering(1, 0))
52        .with_paragraph(Paragraph::with_text("Second item").with_numbering(1, 0))
53        .with_paragraph(Paragraph::with_text("A sub-item, one level deeper").with_numbering(1, 1))
54        .with_paragraph(heading("Numbered list", true))
55        .with_paragraph(Paragraph::with_text("First step").with_numbering(2, 0))
56        .with_paragraph(Paragraph::with_text("Second step").with_numbering(2, 0))
57        .with_paragraph(
58            Paragraph::with_text("A sub-step, cumulatively numbered").with_numbering(2, 1),
59        )
60        .with_paragraph(heading(
61            "Custom multi-level list (roman numerals, then letters)",
62            true,
63        ))
64        .with_paragraph(Paragraph::with_text("First top-level item").with_numbering(3, 0))
65        .with_paragraph(Paragraph::with_text("A lettered sub-item").with_numbering(3, 1))
66        .with_paragraph(Paragraph::with_text("Second top-level item").with_numbering(3, 0));
67
68    document.save_to_file(&path)?;
69    println!("Wrote {}", path.display());
70    Ok(())
71}
Source

pub fn with_font_family(self, font_family: impl Into<String>) -> Style

Sets this style’s font family/typeface and returns it for chaining.

Source

pub fn with_highlight(self, highlight: Highlight) -> Style

Sets this style’s highlight color and returns it for chaining.

Source

pub fn with_strike(self, strike: bool) -> Style

Sets whether text in this style is struck through and returns it for chaining.

Source

pub fn with_vertical_align(self, vertical_align: VerticalAlign) -> Style

Sets this style’s vertical alignment (superscript/subscript) and returns it for chaining.

Source

pub fn with_small_caps(self, small_caps: bool) -> Style

Sets whether text in this style is displayed as small caps and returns it for chaining.

Source

pub fn with_all_caps(self, all_caps: bool) -> Style

Sets whether text in this style is displayed as all caps and returns it for chaining.

Source

pub fn with_shading_color(self, shading_color: impl Into<String>) -> Style

Sets this style’s background shading color (a 6-digit RGB hex string, no leading #) and returns it for chaining.

Source

pub fn with_text_border(self, text_border: bool) -> Style

Sets whether text in this style has a border and returns it for chaining.

Source

pub fn with_character_spacing(self, character_spacing: i16) -> Style

Sets this style’s character spacing adjustment, in twips, and returns it for chaining.

Source

pub fn with_vertical_position(self, vertical_position: i16) -> Style

Sets this style’s vertical position, raised or lowered from the baseline, in half-points, and returns it for chaining.

Source

pub fn with_hidden(self, hidden: bool) -> Style

Sets whether text in this style is hidden and returns it for chaining.

Source

pub fn with_alignment(self, alignment: Alignment) -> Style

Sets this style’s paragraph alignment and returns it for chaining. Only meaningful for StyleKind::Paragraph — see the field’s doc comment.

Source

pub fn with_line_spacing(self, line_spacing: u32) -> Style

Sets this style’s line spacing (in w:spacing’s “auto” units — see Paragraph.line_spacing’s doc comment) and returns it for chaining. Only meaningful for StyleKind::Paragraph.

Source

pub fn with_space_before(self, space_before: u32) -> Style

Sets this style’s extra space before a paragraph, in twips, and returns it for chaining. Only meaningful for StyleKind::Paragraph.

Source

pub fn with_space_after(self, space_after: u32) -> Style

Sets this style’s extra space after a paragraph, in twips, and returns it for chaining. Only meaningful for StyleKind::Paragraph.

Source

pub fn with_paragraph_shading_color( self, paragraph_shading_color: impl Into<String>, ) -> Style

Sets this style’s paragraph background shading color and returns it for chaining. Only meaningful for StyleKind::Paragraph — see paragraph_shading_color’s doc comment for how this differs from with_shading_color.

Source

pub fn with_paragraph_border(self, paragraph_border: bool) -> Style

Sets whether this style draws a border around the paragraph and returns it for chaining. Only meaningful for StyleKind::Paragraph — see paragraph_border’s doc comment for how this differs from with_text_border.

Source

pub fn with_keep_with_next(self, keep_with_next: bool) -> Style

Sets whether this style keeps its paragraph on the same page as the one following it and returns it for chaining. Only meaningful for StyleKind::Paragraph. See keep_with_next’s doc comment.

Source

pub fn with_keep_lines_together(self, keep_lines_together: bool) -> Style

Sets whether this style keeps its paragraph’s lines together on the same page and returns it for chaining. Only meaningful for StyleKind::Paragraph. See keep_lines_together’s doc comment.

Source

pub fn with_page_break_before(self, page_break_before: bool) -> Style

Sets whether this style forces a page break before its paragraph and returns it for chaining. Only meaningful for StyleKind::Paragraph. See page_break_before’s doc comment.

Source

pub fn with_tab(self, tab: TabStop) -> Style

Appends a custom tab stop and returns this style for chaining. Only meaningful for StyleKind::Paragraph. See tabs’s doc comment.

Source

pub fn with_contextual_spacing(self, contextual_spacing: bool) -> Style

Sets whether this style ignores spacing above/below when adjacent to a paragraph sharing the same style and returns it for chaining. Only meaningful for StyleKind::Paragraph. See contextual_spacing’s doc comment.

Trait Implementations§

Source§

impl Clone for Style

Source§

fn clone(&self) -> Style

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Style

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for Style

Source§

impl PartialEq for Style

Source§

fn eq(&self, other: &Style) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Style

Auto Trait Implementations§

§

impl Freeze for Style

§

impl RefUnwindSafe for Style

§

impl Send for Style

§

impl Sync for Style

§

impl Unpin for Style

§

impl UnsafeUnpin for Style

§

impl UnwindSafe for Style

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.