You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently multiple assignemnt is supported at declaration like this
let(critPos, period) =
if critPos1 > critPos2 {(critPos1, period1)}else{(critPos2, period2)};
I think it would be nice to be able do something like this:
// "improved" version of maximal_suffix in src/libcore/str.rsfnmaximal_suffix(arr:&[u8],reversed:bool) -> (uint,uint){letmut left = -1;// Corresponds to i in the paperletmut right = 0;// Corresponds to j in the paperletmut offset = 1;// Corresponds to k in the paperletmut period = 1;// Corresponds to p in the paperwhile right + offset < arr.len(){let(a, b) =
if reversed {(arr[left + offset], arr[right + offset])}else{(arr[right + offset], arr[left + offset])};// THIS IS THE IMPORTANT PART(left, right, offset, period) =
if a < b {// Suffix is smaller, period is entire prefix so far.(left, right + offset,1, right - left)}elseif a == b {// Advance through repetition of the current period.if offset == period {(left, right + offset,1, period)}else{(left, right, offset + 1, period)}}else{// Suffix is larger, start over from current location.(right, right + 1,1,1)};}(left + 1, period)}
Currently something similar is at the moment only possible with a small workaround:
fnmaximal_suffix(arr:&[u8],reversed:bool) -> (uint,uint){letmut left = -1;// Corresponds to i in the paperletmut right = 0;// Corresponds to j in the paperletmut offset = 1;// Corresponds to k in the paperletmut period = 1;// Corresponds to p in the paperwhile right + offset < arr.len(){let(a, b) =
if reversed {(arr[left + offset], arr[right + offset])}else{(arr[right + offset], arr[left + offset])};// HERE I NEED TO INTRODUCE TEMPORARY VARIABLESlet(left_temp, right_temp, offset_temp, period_temp) =
if a < b {// Suffix is smaller, period is entire prefix so far.(left, right + offset,1, right - left)}elseif a == b {// Advance through repetition of the current period.if offset == period {(left, right + offset,1, period)}else{(left, right, offset + 1, period)}}else{// Suffix is larger, start over from current location.(right, right + 1,1,1)};// AND NOW I CAN PUT THE VALUES BACK IN THE REAL VARIABLES
left = left_temp;
right = right_temp;
offset = offset_temp;
period = period_temp;}(left + 1, period)}
The text was updated successfully, but these errors were encountered:
…ange-pattern, r=Veykril
fix: goto-definition for constants inside range pattern
Fixrust-lang#15653.
This PR addresses the issue where it was not possible to navigate to constants in range patterns, specifically including two major changes:
1. Previously, both the `start` and `end` fields in `Pat::Range` were of type `LiteralOrConst`. When performing `goto-definition` on constants inside range patterns, r-a would use `resolve_bind_pat_to_const` to find their definitions. However, because the content of a `Const` is not `Pat` but `Path`, it was not stored in the `source_map`, so `resolve_bind_pat_to_const` would returns `None`. This PR changes them to `Const(PatId)`, so that during the lowering process, they are considered as a `pat`, allowing their definitions to be found later through `resolve_bind_pat_to_const`.
2. The process related to range patterns in MIR-lowering has been modified to correctly handle the above changes.
Currently multiple assignemnt is supported at declaration like this
I think it would be nice to be able do something like this:
Currently something similar is at the moment only possible with a small workaround:
The text was updated successfully, but these errors were encountered: