Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4d31842f authored by Martin Geisler's avatar Martin Geisler
Browse files

pdl: Change &String to &str for a simpler API

Test: atest pdl_tests pdl_rust_generator_tests_{le,be}
Change-Id: Icea91f71f7d22aa64ad191f084503ccbe9ac36a3
parent eac8c46d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -240,7 +240,7 @@ impl Decl {
        }
    }

    pub fn id(&self) -> Option<&String> {
    pub fn id(&self) -> Option<&str> {
        match self {
            Decl::Test { .. } => None,
            Decl::Checksum { id, .. }
@@ -271,7 +271,7 @@ impl Field {
        }
    }

    pub fn id(&self) -> Option<&String> {
    pub fn id(&self) -> Option<&str> {
        match self {
            Field::Checksum { .. }
            | Field::Padding { .. }
+2 −2
Original line number Diff line number Diff line
@@ -369,7 +369,7 @@ impl<'d> PacketScope<'d> {
        // Check field shadowing.
        for f in self.fields.iter().map(|f| f.0.last().unwrap()) {
            if let Some(id) = f.id() {
                if let Some(prev) = self.all_fields.insert(id.clone(), f) {
                if let Some(prev) = self.all_fields.insert(id.to_string(), f) {
                    result.push(
                        Diagnostic::warning()
                            .with_message(format!("declaration of `{}` shadows parent field", id))
@@ -1292,7 +1292,7 @@ impl File {
        // TODO: switch to try_insert when stable
        for decl in &self.declarations {
            if let Some(id) = decl.id() {
                if let Some(prev) = scope.typedef.insert(id.clone(), decl) {
                if let Some(prev) = scope.typedef.insert(id.to_string(), decl) {
                    result.err_redeclared(id, decl.kind(), decl.loc(), prev.loc())
                }
            }