Add Display to RocStr

This commit is contained in:
Richard Feldman 2022-02-05 22:52:17 -05:00
parent e216d74948
commit 2b5a660178
No known key found for this signature in database
GPG Key ID: 7E4127D1E4241798

View File

@ -2,9 +2,10 @@
#![no_std]
use core::convert::From;
use core::ffi::c_void;
use core::fmt::{self, Display, Formatter};
use core::mem::{ManuallyDrop, MaybeUninit};
use core::ops::Drop;
use core::{fmt, mem, ptr, slice};
use core::{mem, ptr, slice};
// A list of C functions that are being imported
extern "C" {
@ -674,6 +675,12 @@ impl From<&str> for RocStr {
}
}
impl Display for RocStr {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
self.as_str().fmt(f)
}
}
impl fmt::Debug for RocStr {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// RocStr { is_small_str: false, storage: Refcounted(3), elements: [ 1,2,3,4] }