@@ -1041,23 +1041,20 @@ mod tests {
10411041 assert_eq ! ( de. read, vec![ ] ) ;
10421042 assert_eq ! ( de. write, vec![ ] ) ;
10431043
1044- assert_eq ! ( de. next( ) . unwrap( ) , Start ( BytesStart :: borrowed_name( "root" ) ) ) ;
1045- assert_eq ! (
1046- de. peek( ) . unwrap( ) ,
1047- & Start ( BytesStart :: borrowed_name( "inner" ) )
1048- ) ;
1044+ assert_eq ! ( de. next( ) . unwrap( ) , Start ( BytesStart :: new( "root" ) ) ) ;
1045+ assert_eq ! ( de. peek( ) . unwrap( ) , & Start ( BytesStart :: new( "inner" ) ) ) ;
10491046
10501047 // Should skip first <inner> tree
10511048 de. skip ( ) . unwrap ( ) ;
10521049 assert_eq ! ( de. read, vec![ ] ) ;
10531050 assert_eq ! (
10541051 de. write,
10551052 vec![
1056- Start ( BytesStart :: borrowed_name ( "inner" ) ) ,
1057- Text ( BytesText :: from_escaped_str ( "text" ) ) ,
1058- Start ( BytesStart :: borrowed_name ( "inner" ) ) ,
1059- End ( BytesEnd :: borrowed ( "inner" ) ) ,
1060- End ( BytesEnd :: borrowed ( "inner" ) ) ,
1053+ Start ( BytesStart :: new ( "inner" ) ) ,
1054+ Text ( BytesText :: from_escaped ( "text" ) ) ,
1055+ Start ( BytesStart :: new ( "inner" ) ) ,
1056+ End ( BytesEnd :: new ( "inner" ) ) ,
1057+ End ( BytesEnd :: new ( "inner" ) ) ,
10611058 ]
10621059 ) ;
10631060
@@ -1069,8 +1066,8 @@ mod tests {
10691066 // </inner>
10701067 // <target/>
10711068 // </root>
1072- assert_eq ! ( de. next( ) . unwrap( ) , Start ( BytesStart :: borrowed_name ( "next" ) ) ) ;
1073- assert_eq ! ( de. next( ) . unwrap( ) , End ( BytesEnd :: borrowed ( "next" ) ) ) ;
1069+ assert_eq ! ( de. next( ) . unwrap( ) , Start ( BytesStart :: new ( "next" ) ) ) ;
1070+ assert_eq ! ( de. next( ) . unwrap( ) , End ( BytesEnd :: new ( "next" ) ) ) ;
10741071
10751072 // We finish writing. Next call to `next()` should start replay that messages:
10761073 //
@@ -1087,43 +1084,37 @@ mod tests {
10871084 assert_eq ! (
10881085 de. read,
10891086 vec![
1090- Start ( BytesStart :: borrowed_name ( "inner" ) ) ,
1091- Text ( BytesText :: from_escaped_str ( "text" ) ) ,
1092- Start ( BytesStart :: borrowed_name ( "inner" ) ) ,
1093- End ( BytesEnd :: borrowed ( "inner" ) ) ,
1094- End ( BytesEnd :: borrowed ( "inner" ) ) ,
1087+ Start ( BytesStart :: new ( "inner" ) ) ,
1088+ Text ( BytesText :: from_escaped ( "text" ) ) ,
1089+ Start ( BytesStart :: new ( "inner" ) ) ,
1090+ End ( BytesEnd :: new ( "inner" ) ) ,
1091+ End ( BytesEnd :: new ( "inner" ) ) ,
10951092 ]
10961093 ) ;
10971094 assert_eq ! ( de. write, vec![ ] ) ;
1098- assert_eq ! (
1099- de. next( ) . unwrap( ) ,
1100- Start ( BytesStart :: borrowed_name( "inner" ) )
1101- ) ;
1095+ assert_eq ! ( de. next( ) . unwrap( ) , Start ( BytesStart :: new( "inner" ) ) ) ;
11021096
11031097 // Skip `#text` node and consume <inner/> after it
11041098 de. skip ( ) . unwrap ( ) ;
11051099 assert_eq ! (
11061100 de. read,
11071101 vec![
1108- Start ( BytesStart :: borrowed_name ( "inner" ) ) ,
1109- End ( BytesEnd :: borrowed ( "inner" ) ) ,
1110- End ( BytesEnd :: borrowed ( "inner" ) ) ,
1102+ Start ( BytesStart :: new ( "inner" ) ) ,
1103+ End ( BytesEnd :: new ( "inner" ) ) ,
1104+ End ( BytesEnd :: new ( "inner" ) ) ,
11111105 ]
11121106 ) ;
11131107 assert_eq ! (
11141108 de. write,
11151109 vec![
11161110 // This comment here to keep the same formatting of both arrays
11171111 // otherwise rustfmt suggest one-line it
1118- Text ( BytesText :: from_escaped_str ( "text" ) ) ,
1112+ Text ( BytesText :: from_escaped ( "text" ) ) ,
11191113 ]
11201114 ) ;
11211115
1122- assert_eq ! (
1123- de. next( ) . unwrap( ) ,
1124- Start ( BytesStart :: borrowed_name( "inner" ) )
1125- ) ;
1126- assert_eq ! ( de. next( ) . unwrap( ) , End ( BytesEnd :: borrowed( "inner" ) ) ) ;
1116+ assert_eq ! ( de. next( ) . unwrap( ) , Start ( BytesStart :: new( "inner" ) ) ) ;
1117+ assert_eq ! ( de. next( ) . unwrap( ) , End ( BytesEnd :: new( "inner" ) ) ) ;
11271118
11281119 // We finish writing. Next call to `next()` should start replay messages:
11291120 //
@@ -1138,22 +1129,16 @@ mod tests {
11381129 assert_eq ! (
11391130 de. read,
11401131 vec![
1141- Text ( BytesText :: from_escaped_str ( "text" ) ) ,
1142- End ( BytesEnd :: borrowed ( "inner" ) ) ,
1132+ Text ( BytesText :: from_escaped ( "text" ) ) ,
1133+ End ( BytesEnd :: new ( "inner" ) ) ,
11431134 ]
11441135 ) ;
11451136 assert_eq ! ( de. write, vec![ ] ) ;
1146- assert_eq ! (
1147- de. next( ) . unwrap( ) ,
1148- Text ( BytesText :: from_escaped_str( "text" ) )
1149- ) ;
1150- assert_eq ! ( de. next( ) . unwrap( ) , End ( BytesEnd :: borrowed( "inner" ) ) ) ;
1151- assert_eq ! (
1152- de. next( ) . unwrap( ) ,
1153- Start ( BytesStart :: borrowed_name( "target" ) )
1154- ) ;
1155- assert_eq ! ( de. next( ) . unwrap( ) , End ( BytesEnd :: borrowed( "target" ) ) ) ;
1156- assert_eq ! ( de. next( ) . unwrap( ) , End ( BytesEnd :: borrowed( "root" ) ) ) ;
1137+ assert_eq ! ( de. next( ) . unwrap( ) , Text ( BytesText :: from_escaped( "text" ) ) ) ;
1138+ assert_eq ! ( de. next( ) . unwrap( ) , End ( BytesEnd :: new( "inner" ) ) ) ;
1139+ assert_eq ! ( de. next( ) . unwrap( ) , Start ( BytesStart :: new( "target" ) ) ) ;
1140+ assert_eq ! ( de. next( ) . unwrap( ) , End ( BytesEnd :: new( "target" ) ) ) ;
1141+ assert_eq ! ( de. next( ) . unwrap( ) , End ( BytesEnd :: new( "root" ) ) ) ;
11571142 }
11581143
11591144 /// Checks that `read_to_end()` behaves correctly after `skip()`
@@ -1177,19 +1162,19 @@ mod tests {
11771162 assert_eq ! ( de. read, vec![ ] ) ;
11781163 assert_eq ! ( de. write, vec![ ] ) ;
11791164
1180- assert_eq ! ( de. next( ) . unwrap( ) , Start ( BytesStart :: borrowed_name ( "root" ) ) ) ;
1165+ assert_eq ! ( de. next( ) . unwrap( ) , Start ( BytesStart :: new ( "root" ) ) ) ;
11811166
11821167 // Skip the <skip> tree
11831168 de. skip ( ) . unwrap ( ) ;
11841169 assert_eq ! ( de. read, vec![ ] ) ;
11851170 assert_eq ! (
11861171 de. write,
11871172 vec![
1188- Start ( BytesStart :: borrowed_name ( "skip" ) ) ,
1189- Text ( BytesText :: from_escaped_str ( "text" ) ) ,
1190- Start ( BytesStart :: borrowed_name ( "skip" ) ) ,
1191- End ( BytesEnd :: borrowed ( "skip" ) ) ,
1192- End ( BytesEnd :: borrowed ( "skip" ) ) ,
1173+ Start ( BytesStart :: new ( "skip" ) ) ,
1174+ Text ( BytesText :: from_escaped ( "text" ) ) ,
1175+ Start ( BytesStart :: new ( "skip" ) ) ,
1176+ End ( BytesEnd :: new ( "skip" ) ) ,
1177+ End ( BytesEnd :: new ( "skip" ) ) ,
11931178 ]
11941179 ) ;
11951180
@@ -1200,20 +1185,17 @@ mod tests {
12001185 // <skip/>
12011186 // </skip>
12021187 // </root>
1203- assert_eq ! (
1204- de. next( ) . unwrap( ) ,
1205- Start ( BytesStart :: borrowed_name( "target" ) )
1206- ) ;
1188+ assert_eq ! ( de. next( ) . unwrap( ) , Start ( BytesStart :: new( "target" ) ) ) ;
12071189 de. read_to_end ( QName ( b"target" ) ) . unwrap ( ) ;
12081190 assert_eq ! ( de. read, vec![ ] ) ;
12091191 assert_eq ! (
12101192 de. write,
12111193 vec![
1212- Start ( BytesStart :: borrowed_name ( "skip" ) ) ,
1213- Text ( BytesText :: from_escaped_str ( "text" ) ) ,
1214- Start ( BytesStart :: borrowed_name ( "skip" ) ) ,
1215- End ( BytesEnd :: borrowed ( "skip" ) ) ,
1216- End ( BytesEnd :: borrowed ( "skip" ) ) ,
1194+ Start ( BytesStart :: new ( "skip" ) ) ,
1195+ Text ( BytesText :: from_escaped ( "text" ) ) ,
1196+ Start ( BytesStart :: new ( "skip" ) ) ,
1197+ End ( BytesEnd :: new ( "skip" ) ) ,
1198+ End ( BytesEnd :: new ( "skip" ) ) ,
12171199 ]
12181200 ) ;
12191201
@@ -1231,19 +1213,19 @@ mod tests {
12311213 assert_eq ! (
12321214 de. read,
12331215 vec![
1234- Start ( BytesStart :: borrowed_name ( "skip" ) ) ,
1235- Text ( BytesText :: from_escaped_str ( "text" ) ) ,
1236- Start ( BytesStart :: borrowed_name ( "skip" ) ) ,
1237- End ( BytesEnd :: borrowed ( "skip" ) ) ,
1238- End ( BytesEnd :: borrowed ( "skip" ) ) ,
1216+ Start ( BytesStart :: new ( "skip" ) ) ,
1217+ Text ( BytesText :: from_escaped ( "text" ) ) ,
1218+ Start ( BytesStart :: new ( "skip" ) ) ,
1219+ End ( BytesEnd :: new ( "skip" ) ) ,
1220+ End ( BytesEnd :: new ( "skip" ) ) ,
12391221 ]
12401222 ) ;
12411223 assert_eq ! ( de. write, vec![ ] ) ;
12421224
1243- assert_eq ! ( de. next( ) . unwrap( ) , Start ( BytesStart :: borrowed_name ( "skip" ) ) ) ;
1225+ assert_eq ! ( de. next( ) . unwrap( ) , Start ( BytesStart :: new ( "skip" ) ) ) ;
12441226 de. read_to_end ( QName ( b"skip" ) ) . unwrap ( ) ;
12451227
1246- assert_eq ! ( de. next( ) . unwrap( ) , End ( BytesEnd :: borrowed ( "root" ) ) ) ;
1228+ assert_eq ! ( de. next( ) . unwrap( ) , End ( BytesEnd :: new ( "root" ) ) ) ;
12471229 }
12481230
12491231 /// Checks that limiting buffer size works correctly
@@ -1293,31 +1275,25 @@ mod tests {
12931275 "# ,
12941276 ) ;
12951277
1296- assert_eq ! ( de. next( ) . unwrap( ) , Start ( BytesStart :: borrowed_name ( "root" ) ) ) ;
1278+ assert_eq ! ( de. next( ) . unwrap( ) , Start ( BytesStart :: new ( "root" ) ) ) ;
12971279
12981280 assert_eq ! (
12991281 de. next( ) . unwrap( ) ,
1300- Start ( BytesStart :: borrowed ( r#"tag a="1""# , 3 ) )
1282+ Start ( BytesStart :: from_content ( r#"tag a="1""# , 3 ) )
13011283 ) ;
13021284 assert_eq ! ( de. read_to_end( QName ( b"tag" ) ) . unwrap( ) , ( ) ) ;
13031285
13041286 assert_eq ! (
13051287 de. next( ) . unwrap( ) ,
1306- Start ( BytesStart :: borrowed ( r#"tag a="2""# , 3 ) )
1288+ Start ( BytesStart :: from_content ( r#"tag a="2""# , 3 ) )
13071289 ) ;
1308- assert_eq ! (
1309- de. next( ) . unwrap( ) ,
1310- CData ( BytesCData :: from_str( "cdata content" ) )
1311- ) ;
1312- assert_eq ! ( de. next( ) . unwrap( ) , End ( BytesEnd :: borrowed( "tag" ) ) ) ;
1290+ assert_eq ! ( de. next( ) . unwrap( ) , CData ( BytesCData :: new( "cdata content" ) ) ) ;
1291+ assert_eq ! ( de. next( ) . unwrap( ) , End ( BytesEnd :: new( "tag" ) ) ) ;
13131292
1314- assert_eq ! (
1315- de. next( ) . unwrap( ) ,
1316- Start ( BytesStart :: borrowed_name( "self-closed" ) )
1317- ) ;
1293+ assert_eq ! ( de. next( ) . unwrap( ) , Start ( BytesStart :: new( "self-closed" ) ) ) ;
13181294 assert_eq ! ( de. read_to_end( QName ( b"self-closed" ) ) . unwrap( ) , ( ) ) ;
13191295
1320- assert_eq ! ( de. next( ) . unwrap( ) , End ( BytesEnd :: borrowed ( "root" ) ) ) ;
1296+ assert_eq ! ( de. next( ) . unwrap( ) , End ( BytesEnd :: new ( "root" ) ) ) ;
13211297 assert_eq ! ( de. next( ) . unwrap( ) , Eof ) ;
13221298 }
13231299
@@ -1385,18 +1361,18 @@ mod tests {
13851361 assert_eq ! (
13861362 events,
13871363 vec![
1388- Start ( BytesStart :: borrowed (
1364+ Start ( BytesStart :: from_content (
13891365 r#"item name="hello" source="world.rs""# ,
13901366 4
13911367 ) ) ,
1392- Text ( BytesText :: from_escaped_str ( "Some text" ) ) ,
1393- End ( BytesEnd :: borrowed ( "item" ) ) ,
1394- Start ( BytesStart :: borrowed ( "item2" , 5 ) ) ,
1395- End ( BytesEnd :: borrowed ( "item2" ) ) ,
1396- Start ( BytesStart :: borrowed ( "item3" , 5 ) ) ,
1397- End ( BytesEnd :: borrowed ( "item3" ) ) ,
1398- Start ( BytesStart :: borrowed ( r#"item4 value="world" "# , 5 ) ) ,
1399- End ( BytesEnd :: borrowed ( "item4" ) ) ,
1368+ Text ( BytesText :: from_escaped ( "Some text" ) ) ,
1369+ End ( BytesEnd :: new ( "item" ) ) ,
1370+ Start ( BytesStart :: from_content ( "item2" , 5 ) ) ,
1371+ End ( BytesEnd :: new ( "item2" ) ) ,
1372+ Start ( BytesStart :: from_content ( "item3" , 5 ) ) ,
1373+ End ( BytesEnd :: new ( "item3" ) ) ,
1374+ Start ( BytesStart :: from_content ( r#"item4 value="world" "# , 5 ) ) ,
1375+ End ( BytesEnd :: new ( "item4" ) ) ,
14001376 ]
14011377 )
14021378 }
@@ -1416,7 +1392,7 @@ mod tests {
14161392
14171393 assert_eq ! (
14181394 reader. next( ) . unwrap( ) ,
1419- DeEvent :: Start ( BytesStart :: borrowed ( "item " , 4 ) )
1395+ DeEvent :: Start ( BytesStart :: from_content ( "item " , 4 ) )
14201396 ) ;
14211397 reader. read_to_end ( QName ( b"item" ) ) . unwrap ( ) ;
14221398 assert_eq ! ( reader. next( ) . unwrap( ) , DeEvent :: Eof ) ;
0 commit comments