-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix missing generics on builder entry point where concrete types are …
…specified on the impl. (#62)
- Loading branch information
Showing
7 changed files
with
127 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
...buildstructor/snapshots/buildstructor__buildstructor__codegen__tests__specialization.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
--- | ||
source: src/buildstructor/codegen.rs | ||
assertion_line: 641 | ||
expression: output | ||
--- | ||
impl Foo<usize> { | ||
fn bound_builder() -> BoundNewFooBuilder { | ||
__foo_bound_new_builder::new() | ||
} | ||
} | ||
///Autogenerated by buildstructor | ||
type BoundNewFooBuilder = __foo_bound_new_builder::__FooBuilder< | ||
(__foo_bound_new_builder::__Required<usize>,), | ||
>; | ||
mod __foo_bound_new_builder { | ||
use super::*; | ||
#[inline(always)] | ||
pub(super) fn new() -> __FooBuilder<(__foo_bound_new_builder::__Required<usize>,)> { | ||
__FooBuilder { | ||
fields: (__required(),), | ||
_phantom: core::default::Default::default(), | ||
} | ||
} | ||
pub(super) struct __Required<T> { | ||
_phantom: std::marker::PhantomData<T>, | ||
} | ||
pub(super) struct __Optional<T> { | ||
lazy: Option<T>, | ||
} | ||
pub(super) struct __Set<T> { | ||
value: T, | ||
} | ||
#[inline(always)] | ||
fn __set<T>(value: T) -> __Set<T> { | ||
__Set { value } | ||
} | ||
#[inline(always)] | ||
fn __required<T>() -> __Required<T> { | ||
__Required::<T> { | ||
_phantom: core::default::Default::default(), | ||
} | ||
} | ||
#[inline(always)] | ||
fn __optional<T>() -> __Optional<T> { | ||
__Optional::<T> { lazy: None } | ||
} | ||
impl<T: Default> From<__Optional<T>> for __Set<T> { | ||
#[inline(always)] | ||
fn from(o: __Optional<T>) -> Self { | ||
__Set { | ||
value: o.lazy.unwrap_or_default(), | ||
} | ||
} | ||
} | ||
pub(super) struct __FooBuilder<__P> { | ||
fields: __P, | ||
_phantom: core::marker::PhantomData<()>, | ||
} | ||
impl __FooBuilder<(__Required<usize>,)> { | ||
#[inline(always)] | ||
pub(super) fn simple(self, simple: usize) -> __FooBuilder<(__Set<usize>,)> { | ||
let simple = simple; | ||
__FooBuilder { | ||
fields: (__set(simple),), | ||
_phantom: core::default::Default::default(), | ||
} | ||
} | ||
} | ||
impl<__P0: Into<__Set<usize>>> __FooBuilder<(__P0,)> { | ||
#[inline(always)] | ||
pub(super) fn build(self) -> Foo<usize> { | ||
Foo::bound_new(self.fields.0.into().value) | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters