ToSharedStr

Trait ToSharedStr 

Source
pub trait ToSharedStr {
    // Required method
    fn to_shared_str(&self) -> SharedStr;
}
Expand description

A trait that converts the source to a SharedStr without consuming it

use flexstr::ToSharedStr;

let a = "This is a heap allocated string!!!!!".to_shared_str();
assert!(a.is_heap());

Required Methods§

Source

fn to_shared_str(&self) -> SharedStr

Converts the source to a SharedStr without consuming it

Implementations on Foreign Types§

Source§

impl ToSharedStr for bool

Source§

fn to_shared_str(&self) -> SharedStr

use flexstr::ToSharedStr;

let s = false.to_shared_str();
assert!(s.is_static());
assert_eq!(s, "false");
Source§

impl ToSharedStr for char

Source§

fn to_shared_str(&self) -> SharedStr

use flexstr::ToSharedStr;

let s = '☺'.to_shared_str();
assert!(s.is_inline());
assert_eq!(s, "☺");
Source§

impl ToSharedStr for f32

Source§

fn to_shared_str(&self) -> SharedStr

use flexstr::ToSharedStr;

let s = 123.456f32.to_shared_str();
assert!(s.is_inline());
assert_eq!(s, "123.456");
Source§

impl ToSharedStr for f64

Source§

fn to_shared_str(&self) -> SharedStr

use flexstr::ToSharedStr;

let s = 123.456f64.to_shared_str();
assert!(s.is_inline());
assert_eq!(s, "123.456");
Source§

impl ToSharedStr for i8

Source§

fn to_shared_str(&self) -> SharedStr

use flexstr::ToSharedStr;

let s = 123i8.to_shared_str();
assert!(s.is_inline());
assert_eq!(s, "123");
Source§

impl ToSharedStr for i16

Source§

fn to_shared_str(&self) -> SharedStr

use flexstr::ToSharedStr;

let s = 123i16.to_shared_str();
assert!(s.is_inline());
assert_eq!(s, "123");
Source§

impl ToSharedStr for i32

Source§

fn to_shared_str(&self) -> SharedStr

use flexstr::ToSharedStr;

let s = 123i32.to_shared_str();
assert!(s.is_inline());
assert_eq!(s, "123");
Source§

impl ToSharedStr for i64

Source§

fn to_shared_str(&self) -> SharedStr

use flexstr::ToSharedStr;

let s = 123i64.to_shared_str();
assert!(s.is_inline());
assert_eq!(s, "123");
Source§

impl ToSharedStr for i128

Source§

fn to_shared_str(&self) -> SharedStr

use flexstr::ToSharedStr;

let s = 123i128.to_shared_str();
assert!(s.is_inline());
assert_eq!(s, "123");
Source§

impl ToSharedStr for isize

Source§

fn to_shared_str(&self) -> SharedStr

use flexstr::ToSharedStr;

let s = 123isize.to_shared_str();
assert!(s.is_inline());
assert_eq!(s, "123");
Source§

impl ToSharedStr for str

Source§

fn to_shared_str(&self) -> SharedStr

use flexstr::ToSharedStr;

// Don't use for literals - use `into_local_str` instead
let a = "test".to_shared_str();
assert!(a.is_inline());
Source§

impl ToSharedStr for u8

Source§

fn to_shared_str(&self) -> SharedStr

use flexstr::ToSharedStr;

let s = 123u8.to_shared_str();
assert!(s.is_inline());
assert_eq!(s, "123");
Source§

impl ToSharedStr for u16

Source§

fn to_shared_str(&self) -> SharedStr

use flexstr::ToSharedStr;

let s = 123u16.to_shared_str();
assert!(s.is_inline());
assert_eq!(s, "123");
Source§

impl ToSharedStr for u32

Source§

fn to_shared_str(&self) -> SharedStr

use flexstr::ToSharedStr;

let s = 123u32.to_shared_str();
assert!(s.is_inline());
assert_eq!(s, "123");
Source§

impl ToSharedStr for u64

Source§

fn to_shared_str(&self) -> SharedStr

use flexstr::ToSharedStr;

let s = 123u64.to_shared_str();
assert!(s.is_inline());
assert_eq!(s, "123");
Source§

impl ToSharedStr for u128

Source§

fn to_shared_str(&self) -> SharedStr

use flexstr::ToSharedStr;

let s = 123u128.to_shared_str();
assert!(s.is_inline());
assert_eq!(s, "123");
Source§

impl ToSharedStr for usize

Source§

fn to_shared_str(&self) -> SharedStr

use flexstr::ToSharedStr;

let s = 123usize.to_shared_str();
assert!(s.is_inline());
assert_eq!(s, "123");

Implementors§

Source§

impl<HEAP> ToSharedStr for FlexStr<STRING_SIZED_INLINE, PTR_SIZED_PAD, PTR_SIZED_PAD, HEAP>
where HEAP: Clone + Deref<Target = str>,