6363< a href =#63 id =63 data-nosnippet > 63</ a > /// Errors if there are duplicate bindings or if any binding index is greater than
6464< a href =#64 id =64 data-nosnippet > 64</ a > /// the device's limits.
6565< a href =#65 id =65 data-nosnippet > 65</ a > </ span > < span class ="kw "> pub fn </ span > from_entries(
66- < a href =#66 id =66 data-nosnippet > 66</ a > device_limits : < span class ="kw-2 "> &</ span > wgt::Limits ,
67- < a href =#67 id =67 data-nosnippet > 67</ a > entries: < span class ="kw-2 " > & < /span > [wgt::BindGroupLayoutEntry],
68- < a href =#68 id =68 data-nosnippet > 68</ a > ) -> < span class ="prelude-ty " > Result </ span > < < span class ="self " > Self </ span > , binding_model::CreateBindGroupLayoutError> {
69- < a href =#69 id =69 data-nosnippet > 69</ a > < span class ="kw "> let </ span > < span class ="kw-2 " > mut </ span > inner = FastIndexMap::with_capacity_and_hasher( entries.len(), Default::default());
70- < a href =#70 id =70 data-nosnippet > 70</ a > < span class ="kw "> for </ span > entry < span class ="kw " > in </ span > entries {
71- < a href =#71 id =71 data-nosnippet > 71</ a > < span class ="kw "> if </ span > entry.binding >= device_limits.max_bindings_per_bind_group {
72- < a href =#72 id =72 data-nosnippet > 72</ a > < span class =" kw " > return </ span > < span class =" prelude-val " > Err </ span > (
73- < a href =#73 id =73 data-nosnippet > 73</ a > binding_model::CreateBindGroupLayoutError::InvalidBindingIndex {
74- < a href =#74 id =74 data-nosnippet > 74</ a > binding: entry.binding,
75- < a href =#75 id =75 data-nosnippet > 75</ a > maximum: device_limits.max_bindings_per_bind_group,
76- < a href =#76 id =76 data-nosnippet > 76</ a > },
77- < a href =#77 id =77 data-nosnippet > 77</ a > );
78- < a href =#78 id =78 data-nosnippet > 78</ a > }
79- < a href =#79 id =79 data-nosnippet > 79</ a > < span class =" kw " > if </ span > inner.insert(entry.binding, < span class =" kw-2 " > * </ span > entry).is_some() {
80- < a href =#80 id =80 data-nosnippet > 80</ a > < span class ="kw " > return </ span > < span class =" prelude -val "> Err </ span > (binding_model::CreateBindGroupLayoutError::ConflictBinding(
81- < a href =#81 id =81 data-nosnippet > 81</ a > entry.binding,
82- < a href =#82 id =82 data-nosnippet > 82</ a > ));
83- < a href =#83 id =83 data-nosnippet > 83</ a > }
84- < a href =#84 id =84 data-nosnippet > 84</ a > }
85- < a href =#85 id =85 data-nosnippet > 85</ a > inner.sort_unstable_keys();
86- < a href =#86 id =86 data-nosnippet > 86</ a >
87- < a href =#87 id =87 data-nosnippet > 87</ a > < span class =" prelude-val " > Ok </ span > ( < span class =" self " > Self </ span > {
88- < a href =#88 id =88 data-nosnippet > 88</ a > inner,
89- < a href =#89 id =89 data-nosnippet > 89</ a > sorted: < span class ="bool-val " > true </ span > ,
90- < a href =#90 id =90 data-nosnippet > 90</ a > })
91- < a href =#91 id =91 data-nosnippet > 91</ a > }
92- < a href =#92 id =92 data-nosnippet > 92</ a >
93- < a href =#93 id =93 data-nosnippet > 93</ a > < span class =" doccomment " > /// Get the count of [`wgt::BindGroupLayoutEntry`]s in this map.
94- < a href =#94 id =94 data-nosnippet > 94</ a > </ span > < span class ="kw " > pub fn </ span > len( < span class =" kw-2 " > & </ span > < span class =" self " > self </ span > ) -> usize {
95- < a href =#95 id =95 data-nosnippet > 95</ a > < span class ="self "> self</ span > .inner.len()
96- < a href =#96 id =96 data-nosnippet > 96</ a > }
97- < a href =#97 id =97 data-nosnippet > 97</ a >
98- < a href =#98 id =98 data-nosnippet > 98</ a > < span class =" doccomment " > /// Get the [`wgt::BindGroupLayoutEntry`] for the given binding index.
99- < a href =#99 id =99 data-nosnippet > 99</ a > </ span > < span class ="kw " > pub fn </ span > get( < span class =" kw-2 " > & </ span > < span class =" self " > self </ span > , binding: u32) -> < span class =" prelude-ty " > Option </ span > < < span class =" kw-2 " > & </ span > wgt::BindGroupLayoutEntry> {
100- < a href =#100 id =100 data-nosnippet > 100</ a > < span class ="self "> self</ span > .inner.get( < span class ="kw-2 "> &</ span > binding)
101- < a href =#101 id =101 data-nosnippet > 101</ a > }
102- < a href =#102 id =102 data-nosnippet > 102</ a >
103- < a href =#103 id =103 data-nosnippet > 103</ a > < span class =" doccomment " > /// Iterator over all the binding indices in this map.
104- < a href =#104 id =104 data-nosnippet > 104</ a > </ span > < span class ="kw "> pub fn </ span > indices (< span class ="kw-2 "> &</ span > < span class ="self "> self</ span > ) -> < span class ="kw "> impl </ span > ExactSizeIterator<Item = u32> + < span class ="lifetime "> '_ </ span > {
105- < a href =#105 id =105 data-nosnippet > 105</ a > < span class ="self "> self</ span > .inner.keys().copied ()
66+ < a href =#66 id =66 data-nosnippet > 66</ a > entries : < span class ="kw-2 "> &</ span > [ wgt::BindGroupLayoutEntry] ,
67+ < a href =#67 id =67 data-nosnippet > 67</ a > ) -> < span class ="prelude-ty " > Result </ span > < < span class =" self " > Self < /span > , binding_model::CreateBindGroupLayoutError> {
68+ < a href =#68 id =68 data-nosnippet > 68</ a > < span class ="kw " > let </ span > < span class ="kw-2 " > mut </ span > inner = FastIndexMap::with_capacity_and_hasher(entries.len(), Default::default());
69+ < a href =#69 id =69 data-nosnippet > 69</ a > < span class ="kw "> for </ span > entry < span class ="kw " > in </ span > entries {
70+ < a href =#70 id =70 data-nosnippet > 70</ a > < span class ="kw "> if </ span > inner.insert( entry.binding, < span class ="kw-2 " > * </ span > entry).is_some() {
71+ < a href =#71 id =71 data-nosnippet > 71</ a > < span class ="kw "> return </ span > < span class =" prelude-val " > Err </ span > (binding_model::CreateBindGroupLayoutError::ConflictBinding(
72+ < a href =#72 id =72 data-nosnippet > 72</ a > entry.binding,
73+ < a href =#73 id =73 data-nosnippet > 73</ a > ));
74+ < a href =#74 id =74 data-nosnippet > 74</ a > }
75+ < a href =#75 id =75 data-nosnippet > 75</ a > }
76+ < a href =#76 id =76 data-nosnippet > 76</ a > inner.sort_unstable_keys();
77+ < a href =#77 id =77 data-nosnippet > 77</ a >
78+ < a href =#78 id =78 data-nosnippet > 78</ a > < span class =" prelude-val " > Ok </ span > ( < span class =" self " > Self </ span > {
79+ < a href =#79 id =79 data-nosnippet > 79</ a > inner,
80+ < a href =#80 id =80 data-nosnippet > 80</ a > sorted: < span class ="bool -val "> true </ span > ,
81+ < a href =#81 id =81 data-nosnippet > 81</ a > })
82+ < a href =#82 id =82 data-nosnippet > 82</ a > }
83+ < a href =#83 id =83 data-nosnippet > 83</ a >
84+ < a href =#84 id =84 data-nosnippet > 84</ a > < span class =" doccomment " > /// Get the count of [`wgt::BindGroupLayoutEntry`]s in this map.
85+ < a href =#85 id =85 data-nosnippet > 85</ a > </ span > < span class =" kw " > pub fn </ span > len( < span class =" kw-2 " > & </ span > < span class =" self " > self </ span > ) -> usize {
86+ < a href =#86 id =86 data-nosnippet > 86</ a > < span class =" self " > self </ span > .inner.len()
87+ < a href =#87 id =87 data-nosnippet > 87</ a > }
88+ < a href =#88 id =88 data-nosnippet > 88</ a >
89+ < a href =#89 id =89 data-nosnippet > 89</ a > < span class ="doccomment " > /// Get the [`wgt::BindGroupLayoutEntry`] for the given binding index.
90+ < a href =#90 id =90 data-nosnippet > 90</ a > </ span > < span class =" kw " > pub fn </ span > get( < span class =" kw-2 " > & </ span > < span class =" self " > self </ span > , binding: u32) -> < span class =" prelude-ty " > Option </ span > < < span class =" kw-2 " > & </ span > wgt::BindGroupLayoutEntry> {
91+ < a href =#91 id =91 data-nosnippet > 91</ a > < span class =" self " > self </ span > .inner.get( < span class =" kw-2 " > & </ span > binding)
92+ < a href =#92 id =92 data-nosnippet > 92</ a > }
93+ < a href =#93 id =93 data-nosnippet > 93</ a >
94+ < a href =#94 id =94 data-nosnippet > 94</ a > < span class ="doccomment " > /// Iterator over all the binding indices in this map.
95+ < a href =#95 id =95 data-nosnippet > 95</ a > </ span > < span class =" kw " > pub fn </ span > indices( < span class =" kw-2 " > & </ span > < span class ="self "> self</ span > ) -> < span class =" kw " > impl </ span > ExactSizeIterator<Item = u32> + < span class =" lifetime " > '_ </ span > {
96+ < a href =#96 id =96 data-nosnippet > 96</ a > < span class =" self " > self </ span > .inner.keys().copied()
97+ < a href =#97 id =97 data-nosnippet > 97</ a > }
98+ < a href =#98 id =98 data-nosnippet > 98</ a >
99+ < a href =#99 id =99 data-nosnippet > 99</ a > < span class ="doccomment " > /// Iterator over all the [` wgt::BindGroupLayoutEntry`]s in this map.
100+ < a href =#100 id =100 data-nosnippet > 100</ a > </ span > < span class =" kw " > pub fn </ span > values( < span class =" kw-2 " > & </ span > < span class ="self "> self</ span > ) -> < span class ="kw " > impl </ span > ExactSizeIterator<Item = < span class =" kw -2 "> &</ span > wgt::BindGroupLayoutEntry> + < span class =" lifetime " > '_ </ span > {
101+ < a href =#101 id =101 data-nosnippet > 101</ a > < span class =" self " > self </ span > .inner.values()
102+ < a href =#102 id =102 data-nosnippet > 102</ a > }
103+ < a href =#103 id =103 data-nosnippet > 103</ a >
104+ < a href =#104 id =104 data-nosnippet > 104</ a > < span class ="kw "> pub fn </ span > iter (< span class ="kw-2 "> &</ span > < span class ="self "> self</ span > ) -> < span class ="kw "> impl </ span > ExactSizeIterator<Item = ( < span class =" kw-2 " > & </ span > u32, < span class =" kw-2 " > & </ span > wgt::BindGroupLayoutEntry) > + < span class ="lifetime "> '_ </ span > {
105+ < a href =#105 id =105 data-nosnippet > 105</ a > < span class ="self "> self</ span > .inner.iter ()
106106< a href =#106 id =106 data-nosnippet > 106</ a > }
107107< a href =#107 id =107 data-nosnippet > 107</ a >
108- < a href =#108 id =108 data-nosnippet > 108</ a > < span class ="doccomment " > /// Iterator over all the [`wgt::BindGroupLayoutEntry`]s in this map.
109- < a href =#109 id =109 data-nosnippet > 109</ a > </ span > < span class =" kw " > pub fn </ span > values( < span class =" kw-2 " > & </ span > < span class ="self "> self</ span > ) -> < span class =" kw " > impl </ span > ExactSizeIterator<Item = < span class =" kw-2 " > & </ span > wgt::BindGroupLayoutEntry> + < span class =" lifetime " > '_ </ span > {
110- < a href =#110 id =110 data-nosnippet > 110</ a > < span class =" self " > self </ span > .inner.values()
111- < a href =#111 id =111 data-nosnippet > 111</ a > }
112- < a href =#112 id =112 data-nosnippet > 112</ a >
113- < a href =#113 id =113 data-nosnippet > 113</ a > < span class =" kw " > pub fn </ span > iter( < span class =" kw-2 " > & </ span > < span class ="self "> self</ span > ) -> < span class =" kw " > impl </ span > ExactSizeIterator<Item = (< span class ="kw-2 "> &</ span > u32, < span class =" kw-2 " > & </ span > wgt::BindGroupLayoutEntry)> + < span class =" lifetime " > '_ </ span > {
114- < a href =#114 id =114 data-nosnippet > 114</ a > < span class =" self " > self </ span > .inner.iter()
115- < a href =#115 id =115 data-nosnippet > 115</ a > }
116- < a href =#116 id =116 data-nosnippet > 116</ a >
117- < a href =#117 id =117 data-nosnippet > 117</ a > < span class =" kw " > pub fn </ span > is_empty( < span class ="kw-2 " > & </ span > < span class ="self " > self </ span > ) -> bool {
118- < a href =#118 id =118 data-nosnippet > 118</ a > < span class ="self "> self</ span > .inner.is_empty( )
108+ < a href =#108 id =108 data-nosnippet > 108</ a > < span class ="kw " > pub fn </ span > is_empty( < span class =" kw-2 " > & </ span > < span class =" self " > self </ span > ) -> bool {
109+ < a href =#109 id =109 data-nosnippet > 109</ a > < span class ="self "> self</ span > .inner.is_empty()
110+ < a href =#110 id =110 data-nosnippet > 110</ a > }
111+ < a href =#111 id =111 data-nosnippet > 111</ a >
112+ < a href =#112 id =112 data-nosnippet > 112</ a > < span class =" kw " > pub fn </ span > contains_key( < span class =" kw-2 " > & </ span > < span class =" self " > self </ span > , key: u32) -> bool {
113+ < a href =#113 id =113 data-nosnippet > 113</ a > < span class ="self "> self</ span > .inner.contains_key (< span class ="kw-2 "> &</ span > key)
114+ < a href =#114 id =114 data-nosnippet > 114</ a > }
115+ < a href =#115 id =115 data-nosnippet > 115</ a >
116+ < a href =#116 id =116 data-nosnippet > 116</ a > < span class =" kw " > pub fn </ span > entry( < span class =" kw-2 " > &mut </ span > < span class =" self " > self </ span > , key: u32) -> indexmap::map::Entry< < span class =" lifetime " > '_ </ span > , u32, wgt::BindGroupLayoutEntry> {
117+ < a href =#117 id =117 data-nosnippet > 117</ a > < span class ="self " > self </ span > .sorted = < span class ="bool-val " > false </ span > ;
118+ < a href =#118 id =118 data-nosnippet > 118</ a > < span class ="self "> self</ span > .inner.entry(key )
119119< a href =#119 id =119 data-nosnippet > 119</ a > }
120120< a href =#120 id =120 data-nosnippet > 120</ a >
121- < a href =#121 id =121 data-nosnippet > 121</ a > < span class ="kw "> pub fn </ span > contains_key(< span class ="kw-2 "> &</ span > < span class ="self "> self</ span > , key: u32) -> bool {
122- < a href =#122 id =122 data-nosnippet > 122</ a > < span class ="self "> self</ span > .inner.contains_key(< span class ="kw-2 "> &</ span > key)
123- < a href =#123 id =123 data-nosnippet > 123</ a > }
124- < a href =#124 id =124 data-nosnippet > 124</ a >
125- < a href =#125 id =125 data-nosnippet > 125</ a > < span class ="kw "> pub fn </ span > entry(< span class ="kw-2 "> &mut </ span > < span class ="self "> self</ span > , key: u32) -> indexmap::map::Entry<< span class ="lifetime "> '_</ span > , u32, wgt::BindGroupLayoutEntry> {
126- < a href =#126 id =126 data-nosnippet > 126</ a > < span class ="self "> self</ span > .sorted = < span class ="bool-val "> false</ span > ;
127- < a href =#127 id =127 data-nosnippet > 127</ a > < span class ="self "> self</ span > .inner.entry(key)
128- < a href =#128 id =128 data-nosnippet > 128</ a > }
129- < a href =#129 id =129 data-nosnippet > 129</ a >
130- < a href =#130 id =130 data-nosnippet > 130</ a > < span class ="kw "> pub fn </ span > sort(< span class ="kw-2 "> &mut </ span > < span class ="self "> self</ span > ) {
131- < a href =#131 id =131 data-nosnippet > 131</ a > < span class ="self "> self</ span > .inner.sort_unstable_keys();
132- < a href =#132 id =132 data-nosnippet > 132</ a > < span class ="self "> self</ span > .sorted = < span class ="bool-val "> true</ span > ;
133- < a href =#133 id =133 data-nosnippet > 133</ a > }
134- < a href =#134 id =134 data-nosnippet > 134</ a > }</ code > </ pre > </ div > </ section > </ main > </ body > </ html >
121+ < a href =#121 id =121 data-nosnippet > 121</ a > < span class ="kw "> pub fn </ span > sort(< span class ="kw-2 "> &mut </ span > < span class ="self "> self</ span > ) {
122+ < a href =#122 id =122 data-nosnippet > 122</ a > < span class ="self "> self</ span > .inner.sort_unstable_keys();
123+ < a href =#123 id =123 data-nosnippet > 123</ a > < span class ="self "> self</ span > .sorted = < span class ="bool-val "> true</ span > ;
124+ < a href =#124 id =124 data-nosnippet > 124</ a > }
125+ < a href =#125 id =125 data-nosnippet > 125</ a > }</ code > </ pre > </ div > </ section > </ main > </ body > </ html >
0 commit comments