Skip to content

Commit 08ce728

Browse files
committed
rstring: fix invalid strict dumb implementation
1 parent 9a01315 commit 08ce728

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

rust/src/embedded.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -439,26 +439,26 @@ impl<const MIN_LEN: usize, const MAX_LEN: usize> StrictDecode
439439
}
440440
}
441441

442-
impl<C: RestrictedCharSet, C1: RestrictedCharSet, const MIN_LEN: usize, const MAX_LEN: usize>
443-
StrictType for RString<C, C1, MIN_LEN, MAX_LEN>
442+
impl<C1: RestrictedCharSet, C: RestrictedCharSet, const MIN_LEN: usize, const MAX_LEN: usize>
443+
StrictType for RString<C1, C, MIN_LEN, MAX_LEN>
444444
{
445445
const STRICT_LIB_NAME: &'static str = LIB_EMBEDDED;
446446
fn strict_name() -> Option<TypeName> { None }
447447
}
448-
impl<C: RestrictedCharSet, C1: RestrictedCharSet, const MIN_LEN: usize, const MAX_LEN: usize>
449-
StrictDumb for RString<C, C1, MIN_LEN, MAX_LEN>
448+
impl<C1: RestrictedCharSet, C: RestrictedCharSet, const MIN_LEN: usize, const MAX_LEN: usize>
449+
StrictDumb for RString<C1, C, MIN_LEN, MAX_LEN>
450450
{
451451
fn strict_dumb() -> Self {
452452
Self::try_from(format!(
453453
"{}{}",
454454
C1::strict_dumb(),
455-
String::from_utf8(vec![C::strict_dumb().into(); MIN_LEN]).expect("dumb")
455+
String::from_utf8(vec![C::strict_dumb().into(); MIN_LEN - 1]).expect("dumb")
456456
))
457457
.expect("dumb")
458458
}
459459
}
460-
impl<C: RestrictedCharSet, C1: RestrictedCharSet, const MIN_LEN: usize, const MAX_LEN: usize>
461-
StrictEncode for RString<C, C1, MIN_LEN, MAX_LEN>
460+
impl<C1: RestrictedCharSet, C: RestrictedCharSet, const MIN_LEN: usize, const MAX_LEN: usize>
461+
StrictEncode for RString<C1, C, MIN_LEN, MAX_LEN>
462462
{
463463
fn strict_encode<W: TypedWrite>(&self, writer: W) -> io::Result<W> {
464464
debug_assert_ne!(
@@ -473,8 +473,8 @@ impl<C: RestrictedCharSet, C1: RestrictedCharSet, const MIN_LEN: usize, const MA
473473
}
474474
}
475475
}
476-
impl<C: RestrictedCharSet, C1: RestrictedCharSet, const MIN_LEN: usize, const MAX_LEN: usize>
477-
StrictDecode for RString<C, C1, MIN_LEN, MAX_LEN>
476+
impl<C1: RestrictedCharSet, C: RestrictedCharSet, const MIN_LEN: usize, const MAX_LEN: usize>
477+
StrictDecode for RString<C1, C, MIN_LEN, MAX_LEN>
478478
{
479479
fn strict_decode(reader: &mut impl TypedRead) -> Result<Self, DecodeError> {
480480
let bytes = unsafe { reader.read_string::<MAX_LEN>()? };

0 commit comments

Comments
 (0)