Skip to content

feat: Add ToSpanTrait to Spans #9063

@bengineer42

Description

@bengineer42

Feature Request

Describe the Feature Request
Add the ToSpanTrait to Spans to enhance generics

    fn do_something_on_many<TS, T, +ToSpanTrait<TS, T>>(collection: TS){
        collection.to_span().into_iter().map(|c| c.do_something())
   }

Where do_something_on_many can take Span<T>, Array<T> or [T; N] and in some cases of [T; N] It can solve the Non zero compiler issues

Describe Preferred Solution

impl SpanToSpan<T> of ToSpanTrait<Span<T>, T> {
    #[inline]
    fn span(self: @Span<T>) -> Span<T> {
        *self
    }
}

Describe Alternatives

Related Code

Additional Context

If the feature request is approved, would you be willing to submit a PR?
(Help can be provided if you need assistance submitting a PR)

  • Yes
  • No

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions