45
45
46
46
use crate :: alloc:: Global ;
47
47
48
- use crate :: vec :: PlVec ;
48
+ use core :: alloc ;
49
49
#[ cfg( not( no_global_oom_handling) ) ]
50
50
use core:: char:: { decode_utf16, REPLACEMENT_CHARACTER } ;
51
51
use core:: error:: Error ;
@@ -413,8 +413,11 @@ where
413
413
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
414
414
#[ cfg_attr( not( no_global_oom_handling) , derive( Clone ) ) ]
415
415
#[ derive( Debug , PartialEq , Eq ) ]
416
- pub struct FromUtf8Error {
417
- bytes : PlVec < u8 > ,
416
+ pub struct FromUtf8Error < const COOP_PREFERRED : bool >
417
+ where
418
+ [ ( ) ; core:: alloc:: co_alloc_metadata_num_slots_with_preference :: < Global > ( COOP_PREFERRED ) ] : ,
419
+ {
420
+ bytes : Vec < u8 , Global , COOP_PREFERRED > ,
418
421
error : Utf8Error ,
419
422
}
420
423
@@ -584,7 +587,7 @@ where
584
587
/// [`into_bytes`]: String::into_bytes
585
588
#[ inline]
586
589
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
587
- pub fn from_utf8 ( vec : Vec < u8 , Global , COOP_PREFERRED > ) -> Result < String , FromUtf8Error > {
590
+ pub fn from_utf8 ( vec : Vec < u8 , Global , COOP_PREFERRED > ) -> Result < String < COOP_PREFERRED > , FromUtf8Error < COOP_PREFERRED > > {
588
591
match str:: from_utf8 ( & vec) {
589
592
Ok ( ..) => Ok ( String { vec } ) ,
590
593
Err ( e) => Err ( FromUtf8Error { bytes : vec, error : e } ) ,
@@ -1910,7 +1913,9 @@ where
1910
1913
}
1911
1914
}
1912
1915
1913
- impl FromUtf8Error {
1916
+ impl < const COOP_PREFERRED : bool > FromUtf8Error < COOP_PREFERRED >
1917
+ where
1918
+ [ ( ) ; alloc:: co_alloc_metadata_num_slots_with_preference :: < Global > ( COOP_PREFERRED ) ] : , {
1914
1919
/// Returns a slice of [`u8`]s bytes that were attempted to convert to a `String`.
1915
1920
///
1916
1921
/// # Examples
@@ -1951,7 +1956,7 @@ impl FromUtf8Error {
1951
1956
/// ```
1952
1957
#[ must_use = "`self` will be dropped if the result is not used" ]
1953
1958
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1954
- pub fn into_bytes < const COOP_PREFERRED : bool > ( self ) -> Vec < u8 , Global , COOP_PREFERRED >
1959
+ pub fn into_bytes ( self ) -> Vec < u8 , Global , COOP_PREFERRED >
1955
1960
where
1956
1961
[ ( ) ; core:: alloc:: co_alloc_metadata_num_slots_with_preference :: < Global > ( COOP_PREFERRED ) ] : ,
1957
1962
{
@@ -1989,7 +1994,10 @@ impl FromUtf8Error {
1989
1994
}
1990
1995
1991
1996
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1992
- impl fmt:: Display for FromUtf8Error {
1997
+ impl < const COOP_PREFERRED : bool > fmt:: Display for FromUtf8Error < COOP_PREFERRED >
1998
+ where
1999
+ [ ( ) ; core:: alloc:: co_alloc_metadata_num_slots_with_preference :: < Global > ( COOP_PREFERRED ) ] : ,
2000
+ {
1993
2001
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
1994
2002
fmt:: Display :: fmt ( & self . error , f)
1995
2003
}
@@ -2003,7 +2011,10 @@ impl fmt::Display for FromUtf16Error {
2003
2011
}
2004
2012
2005
2013
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2006
- impl Error for FromUtf8Error {
2014
+ impl < const COOP_PREFERRED : bool > Error for FromUtf8Error < COOP_PREFERRED >
2015
+ where
2016
+ [ ( ) ; core:: alloc:: co_alloc_metadata_num_slots_with_preference :: < Global > ( COOP_PREFERRED ) ] : ,
2017
+ {
2007
2018
#[ allow( deprecated) ]
2008
2019
fn description ( & self ) -> & str {
2009
2020
"invalid utf-8"
0 commit comments