File tree Expand file tree Collapse file tree 1 file changed +10
-15
lines changed
src/Weaviate.Client/Models Expand file tree Collapse file tree 1 file changed +10
-15
lines changed Original file line number Diff line number Diff line change 11using System . Collections ;
2+ using System . Diagnostics . CodeAnalysis ;
23
34namespace Weaviate . Client . Models ;
45
5- public class OneOrManyOf < T > : IEnumerable < T >
6+ public class OneOrManyOf < T > ( IEnumerable < T > items ) : IEnumerable < T >
67{
7- private readonly List < T > _items ;
8+ private readonly List < T > _items = [ .. items ] ;
89
9- public OneOrManyOf ( IEnumerable < T > items )
10- {
11- _items = new ( items ) ;
12- }
13-
14- public OneOrManyOf ( params T [ ] item )
15- {
16- _items = new ( item ) ;
17- }
10+ public OneOrManyOf ( params T [ ] items )
11+ : this ( items . AsEnumerable ( ) ) { }
1812
19- public static implicit operator OneOrManyOf < T > ( T item ) => new OneOrManyOf < T > ( item ) ;
13+ public static implicit operator OneOrManyOf < T > ( T item ) => new ( item ) ;
2014
15+ [ return : NotNullIfNotNull ( nameof ( items ) ) ]
2116 public static implicit operator OneOrManyOf < T > ? ( T [ ] ? items ) =>
22- items is null ? null : new OneOrManyOf < T > ( items ) ;
17+ items is null ? null : new ( items ) ;
2318
24- public static implicit operator OneOrManyOf < T > ( List < T > items ) => new OneOrManyOf < T > ( items ) ;
19+ public static implicit operator OneOrManyOf < T > ( List < T > items ) => items ;
2520
26- public static explicit operator T [ ] ( OneOrManyOf < T > list ) => list . _items . ToArray ( ) ;
21+ public static explicit operator T [ ] ( OneOrManyOf < T > list ) => [ .. list . _items ] ;
2722
2823 public IEnumerator < T > GetEnumerator ( ) => _items . GetEnumerator ( ) ;
2924
You can’t perform that action at this time.
0 commit comments