Unverified Commit ac05ffd8 authored by Russell Cohen's avatar Russell Cohen Committed by GitHub
Browse files

Serialize Sets with Vecs (#270)

* Remove non-determinism and use Vecs always instead of Sets

* Remove special casing for sets
parent c62afebd
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -68,8 +68,8 @@ sealed class RustType {
        override val namespace = Namespace

        companion object {
            const val Type = "BTreeSet"
            const val Namespace = "std::collections"
            const val Type = "Vec"
            const val Namespace = "std::vec"
            val RuntimeType = RuntimeType(name = Type, namespace = Namespace, dependency = null)
        }
    }
+1 −6
Original line number Diff line number Diff line
@@ -422,11 +422,6 @@ class HttpProtocolTestGenerator(

        // These tests are not even attempted to be compiled, either because they will not compile
        // or because they are flaky
        private val DisableTests = setOf(
            // This test is flaky because of set ordering serialization https://github.com/awslabs/smithy-rs/issues/37
            "AwsJson11Enums",
            "RestJsonJsonEnums",
            "RestJsonLists"
        )
        private val DisableTests = setOf<String>()
    }
}
+1 −17
Original line number Diff line number Diff line
@@ -162,24 +162,8 @@ class Instantiator(
    }

    private fun renderSet(writer: RustWriter, shape: SetShape, data: ArrayNode, ctx: Ctx) {
        if (symbolProvider.toSymbol(shape).rustType() is RustType.HashSet) {
            if (!data.isEmpty) {
                writer.rustBlock("") {
                    write("let mut ret = #T::new();", RustType.HashSet.RuntimeType)
                    data.forEach { v ->
                        withBlock("ret.insert(", ");") {
                            renderMember(this, shape.member, v, ctx)
                        }
                    }
                    write("ret")
                }
            } else {
                writer.write("#T::new()", RustType.HashSet.RuntimeType)
            }
        } else {
        renderList(writer, shape, data, ctx)
    }
    }

    /**
     * ```rust