Vendor dependencies

This commit is contained in:
2026-08-01 16:11:49 +03:00
parent 7f139a0241
commit 6b5e7f0f8b
29706 changed files with 9575646 additions and 0 deletions
@@ -0,0 +1,22 @@
#[macro_use]
extern crate derive_builder;
/// This is a doc comment for the struct
#[warn(missing_docs)]
#[allow(non_snake_case, dead_code)]
#[derive(Builder)]
struct Lorem {
/// This is a doc comment for a field
field_with_doc_comment: String,
#[allow(missing_docs)]
undocumented: String,
#[allow(non_snake_case)]
CamelCase: i32,
#[cfg(target_os = "macos")]
mac_only: bool,
#[allow(non_snake_case)]
#[cfg(target_os = "linux")]
LinuxOnly: (),
}
fn main() { }
@@ -0,0 +1,24 @@
//! Test that an alias of derive_builder is valid in #[builder(crate = "...")]
//!
//! This test is imperfect, as it still passes without setting `crate = "..."`.
//! This is likely because `derive_builder` is automatically present in 2018
//! without needing the extern crate line.
//!
//! The test will fail if an incorrect alias is used, so it adds limited value.
#[macro_use]
extern crate derive_builder as db;
#[derive(Builder)]
#[builder(crate = "db")]
struct AliasedCrate {
#[builder(setter(into))]
lorem: String,
}
fn main() {
AliasedCrateBuilder::default()
.lorem("hello")
.build()
.unwrap();
}
@@ -0,0 +1,49 @@
//! This test ensures custom errors don't need a conversion from `UninitializedFieldError`
//! if uninitialized fields are impossible.
#[macro_use]
extern crate derive_builder;
#[derive(Default, Builder)]
#[builder(default, build_fn(validate = "check_person", error = "Error"))]
struct Person {
name: String,
age: u16,
}
/// An error that deliberately doesn't have `impl From<UninitializedFieldError>`; as long
/// as `PersonBuilder` uses `Person::default` then missing field errors are never possible.
enum Error {
UnpopularName(String),
UnrealisticAge(u16),
}
fn check_age_realistic(age: u16) -> Result<(), Error> {
if age > 150 {
Err(Error::UnrealisticAge(age))
} else {
Ok(())
}
}
fn check_name_popular(name: &str) -> Result<(), Error> {
if name.starts_with('B') {
Err(Error::UnpopularName(name.to_string()))
} else {
Ok(())
}
}
fn check_person(builder: &PersonBuilder) -> Result<(), Error> {
if let Some(age) = &builder.age {
check_age_realistic(*age)?;
}
if let Some(name) = &builder.name {
check_name_popular(name)?;
}
Ok(())
}
fn main() {}
@@ -0,0 +1,30 @@
#![allow(dead_code)]
#[macro_use]
extern crate derive_builder;
struct Unit;
type Clone = Unit;
type Into = Unit;
type Option = Unit;
type Result = Unit;
type Some = Unit;
type String = Unit;
impl core::fmt::Debug for Unit {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
write!(f, "()")
}
}
impl core::fmt::Display for Unit {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
write!(f, "()")
}
}
#[derive(Builder)]
struct IgnoreEmptyStruct {}
fn main() { }
@@ -0,0 +1,30 @@
//! Test ensuring that default type params gets forwarded to Builder.
#[macro_use]
extern crate derive_builder;
#[derive(Builder)]
#[builder(setter(strip_option))]
struct Settings<T, U = (), C = fn(T) -> U> {
first: T,
#[builder(default)]
second: Option<U>,
#[builder(default)]
third: Option<C>,
}
fn main() {
SettingsBuilder::<usize>::default()
.first(1)
.second(())
.third(|_: usize| ())
.build()
.unwrap();
SettingsBuilder::<usize, usize>::default()
.first(1)
.second(2)
.third(|_: usize| 3)
.build()
.unwrap();
}
@@ -0,0 +1,8 @@
#[macro_use]
extern crate derive_builder;
#[allow(dead_code)]
#[derive(Builder)]
struct IgnoreEmptyStruct {}
fn main() { }
@@ -0,0 +1,16 @@
#[macro_use]
extern crate derive_builder;
#[allow(dead_code)]
#[derive(Builder)]
struct Foo {
lorem: bool,
}
#[allow(dead_code)]
#[derive(Builder)]
struct Bar {
ipsum: bool,
}
fn main() { }