Movatterモバイル変換


[0]ホーム

URL:


alloc::string

TraitToString

1.36.0 ·Source
pub trait ToString {    // Required method    fnto_string(&self) ->String;}
Expand description

A trait for converting a value to aString.

This trait is automatically implemented for any type which implements theDisplay trait. As such,ToString shouldn’t be implemented directly:Display should be implemented instead, and you get theToStringimplementation for free.

Required Methods§

1.0.0 ·Source

fnto_string(&self) ->String

Converts the given value to aString.

§Examples
leti =5;letfive = String::from("5");assert_eq!(five, i.to_string());

Implementors§

1.0.0 ·Source§

impl<T:Display + ?Sized>ToString for T

§Panics

In this implementation, theto_string method panicsif theDisplay implementation returns an error.This indicates an incorrectDisplay implementationsincefmt::Write for String never returns an error itself.


[8]ページ先頭

©2009-2025 Movatter.jp