Vendor dependencies for 0.3.0 release

This commit is contained in:
2025-09-27 10:29:08 -05:00
parent 0c8d39d483
commit 82ab7f317b
26803 changed files with 16134934 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
#[rustversion::attr(not(nightly), ignore = "requires nightly")]
#[cfg_attr(miri, ignore = "incompatible with miri")]
#[test]
fn ui() {
let t = trybuild::TestCases::new();
t.compile_fail("tests/ui/*.rs");
}

57
vendor/erased-serde/tests/readme.rs vendored Normal file
View File

@@ -0,0 +1,57 @@
// Please also update README.md when making changes to this code.
use erased_serde::{Deserializer, Serialize, Serializer};
use std::collections::BTreeMap as Map;
use std::io;
#[test]
fn serialization() {
// Construct some serializers.
let json = &mut serde_json::Serializer::new(io::stdout());
let cbor = &mut serde_cbor::Serializer::new(serde_cbor::ser::IoWrite::new(io::stdout()));
// The values in this map are boxed trait objects. Ordinarily this would not
// be possible with serde::Serializer because of object safety, but type
// erasure makes it possible with erased_serde::Serializer.
let mut formats: Map<&str, Box<dyn Serializer>> = Map::new();
formats.insert("json", Box::new(<dyn Serializer>::erase(json)));
formats.insert("cbor", Box::new(<dyn Serializer>::erase(cbor)));
// These are boxed trait objects as well. Same thing here - type erasure
// makes this possible.
let mut values: Map<&str, Box<dyn Serialize>> = Map::new();
values.insert("vec", Box::new(vec!["a", "b"]));
values.insert("int", Box::new(65536));
// Pick a Serializer out of the formats map.
let format = formats.get_mut("json").unwrap();
// Pick a Serialize out of the values map.
let value = values.get("vec").unwrap();
// This line prints `["a","b"]` to stdout.
value.erased_serialize(format).unwrap();
}
#[test]
fn deserialization() {
static JSON: &[u8] = br#"{"A": 65, "B": 66}"#;
static CBOR: &[u8] = &[162, 97, 65, 24, 65, 97, 66, 24, 66];
// Construct some deserializers.
let json = &mut serde_json::Deserializer::from_slice(JSON);
let cbor = &mut serde_cbor::Deserializer::from_slice(CBOR);
// The values in this map are boxed trait objects, which is not possible
// with the normal serde::Deserializer because of object safety.
let mut formats: Map<&str, Box<dyn Deserializer>> = Map::new();
formats.insert("json", Box::new(<dyn Deserializer>::erase(json)));
formats.insert("cbor", Box::new(<dyn Deserializer>::erase(cbor)));
// Pick a Deserializer out of the formats map.
let format = formats.get_mut("json").unwrap();
let data: Map<String, usize> = erased_serde::deserialize(format).unwrap();
println!("{}", data["A"] + data["B"]);
}

View File

@@ -0,0 +1,9 @@
use erased_serde::serialize_trait_object;
pub trait MyTrait: erased_serde::Serialize {}
serialize_trait_object!(MyTrait);
pub trait MyGenericTrait<'a, T>: erased_serde::Serialize {}
serialize_trait_object!(<'a, T> MyGenericTrait<'a, T>);

View File

@@ -0,0 +1,7 @@
use erased_serde::serialize_trait_object;
pub trait MyTrait {}
serialize_trait_object!(MyTrait);
fn main() {}

View File

@@ -0,0 +1,20 @@
error[E0277]: the trait bound `__T: serde::Serialize` is not satisfied
--> tests/ui/missing-supertrait.rs:5:1
|
5 | serialize_trait_object!(MyTrait);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `serde::Serialize` is not implemented for `__T`, so it does not implement `erased_serde::Serialize`
|
= note: required for `__T` to implement `erased_serde::Serialize`
note: required by a bound in `require_erased_serialize_impl`
--> src/private.rs
|
| pub fn require_erased_serialize_impl<T>()
| ----------------------------- required by a bound in this function
| where
| T: ?Sized + crate::Serialize,
| ^^^^^^^^^^^^^^^^ required by this bound in `require_erased_serialize_impl`
= note: this error originates in the macro `$crate::__internal_serialize_trait_object` which comes from the expansion of the macro `serialize_trait_object` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider further restricting type parameter `__T` with trait `Serialize`
|
5 | serialize_trait_object!(MyTrait + serde_core::ser::Serialize);
| ++++++++++++++++++++++++++++