Skip to content

Commit f7be0a7

Browse files
authored
Merge pull request #45 from strict-types/develop
Fix RString strict dumb encoding. Add more ASCII types
2 parents 9a01315 + 1ab0972 commit f7be0a7

File tree

4 files changed

+693
-40
lines changed

4 files changed

+693
-40
lines changed

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ default-members = ["rust", "rust/derive", "rust/test_helpers"]
44
resolver = "2"
55

66
[workspace.package]
7-
version = "2.8.0"
7+
version = "2.8.1"
88
authors = ["Dr Maxim Orlovsky <[email protected]>"]
99
homepage = "https://strict-types.org"
1010
repository = "https://github.com/strict-types/strict-encoding"

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)