Menu

Tree [20a840] master /
 History

HTTPS access


File Date Author Commit
 blog 2025-06-15 Daniel Pfeiffer Daniel Pfeiffer [20a840] Rename Range wrapper to AnyRange and fully gene...
 src 2025-06-15 Daniel Pfeiffer Daniel Pfeiffer [20a840] Rename Range wrapper to AnyRange and fully gene...
 .gitignore 2025-01-08 Daniel Pfeiffer Daniel Pfeiffer [264c54] 0.1.0
 Cargo.lock 2025-05-02 Daniel Pfeiffer Daniel Pfeiffer [69593c] v0.6.0 Allow all range types (.., ..=) on range...
 Cargo.toml 2025-05-02 Daniel Pfeiffer Daniel Pfeiffer [69593c] v0.6.0 Allow all range types (.., ..=) on range...
 README.md 2025-05-02 Daniel Pfeiffer Daniel Pfeiffer [69593c] v0.6.0 Allow all range types (.., ..=) on range...

Read Me


<g transform="translate(-13 -77)">
<path d="m91 86c0.2 0 0.38 0.064 0.52 0.19 0.14 0.13 0.21 0.31 0.21 0.54 0 0.21-0.072 0.38-0.22 0.51-0.15 0.14-0.32 0.21-0.51 0.21-0.19 0-0.35-0.062-0.5-0.18-0.14-0.12-0.22-0.3-0.22-0.53 0-0.23 0.072-0.41 0.21-0.54 0.14-0.13 0.31-0.19 0.51-0.19z" fill="#2e4fd8" stroke="#fff" stroke-linejoin="bevel" stroke-width=".35" style="paint-order:stroke fill markers">
<path d="m102 84c0 0.41-0.099 0.75-0.29 1-0.2 0.29-0.48 0.51-0.86 0.66-0.38 0.15-0.84 0.22-1.4 0.22-0.52 0-0.96-0.081-1.3-0.24-0.37-0.16-0.64-0.36-0.82-0.6-0.18-0.25-0.27-0.49-0.27-0.73 0-0.16 0.055-0.3 0.17-0.41 0.11-0.12 0.26-0.17 0.43-0.17 0.15 0 0.27 0.038 0.35 0.11 0.081 0.075 0.16 0.18 0.23 0.32 0.15 0.26 0.32 0.46 0.53 0.59 0.21 0.13 0.49 0.19 0.85 0.19 0.29 0 0.53-0.065 0.71-0.19 0.19-0.13 0.28-0.28 0.28-0.45 0-0.26-0.097-0.45-0.29-0.57-0.19-0.12-0.51-0.23-0.95-0.34-0.5-0.13-0.9-0.26-1.2-0.39-0.31-0.14-0.56-0.32-0.75-0.55-0.19-0.23-0.28-0.51-0.28-0.84 0-0.29 0.085-0.57 0.26-0.83 0.17-0.26 0.43-0.47 0.76-0.63 0.34-0.16 0.75-0.24 1.2-0.24 0.37 0 0.71 0.039 1 0.12 0.3 0.078 0.55 0.19 0.75 0.32 0.2 0.13 0.35 0.28 0.46 0.44 0.11 0.16 0.16 0.32 0.16 0.47 0 0.17-0.056 0.31-0.17 0.42-0.11 0.11-0.27 0.16-0.47 0.16-0.15 0-0.28-0.043-0.38-0.13-0.1-0.087-0.22-0.22-0.35-0.39-0.11-0.14-0.24-0.26-0.39-0.35-0.15-0.086-0.35-0.13-0.6-0.13-0.26 0-0.48 0.056-0.65 0.17-0.17 0.11-0.26 0.25-0.26 0.42 0 0.15 0.064 0.28 0.19 0.38 0.13 0.096 0.3 0.18 0.51 0.24 0.22 0.065 0.51 0.14 0.89 0.24 0.45 0.11 0.81 0.24 1.1 0.4 0.29 0.15 0.5 0.34 0.65 0.55 0.15 0.21 0.22 0.45 0.22 0.72zm-8.2-0.2v1.2c0 0.3-0.07 0.52-0.21 0.67-0.14 0.15-0.31 0.22-0.52 0.22-0.21 0-0.38-0.076-0.52-0.23-0.13-0.15-0.2-0.38-0.2-0.67v-4.1c0-0.66 0.24-0.99 0.71-0.99 0.24 0 0.41 0.078 0.52 0.23 0.11 0.16 0.16 0.38 0.17 0.69 0.17-0.3 0.35-0.53 0.53-0.69 0.19-0.15 0.43-0.23 0.73-0.23 0.3 0 0.6 0.078 0.89 0.23 0.29 0.16 0.43 0.36 0.43 0.62 0 0.18-0.061 0.33-0.18 0.45-0.12 0.11-0.25 0.17-0.39 0.17-0.054 0-0.18-0.032-0.39-0.096-0.2-0.069-0.38-0.1-0.53-0.1-0.21 0-0.39 0.059-0.52 0.17-0.13 0.11-0.24 0.28-0.31 0.5-0.074 0.22-0.12 0.49-0.15 0.8-0.029 0.31-0.042 0.68-0.042 1.1zm-3.9-0.59h-2.8c0.0015 0.33 0.067 0.63 0.19 0.89 0.13 0.25 0.3 0.45 0.51 0.58 0.21 0.13 0.45 0.19 0.71 0.19 0.17 0 0.33-0.019 0.47-0.058 0.14-0.043 0.28-0.11 0.42-0.19 0.13-0.091 0.26-0.19 0.37-0.29 0.11-0.099 0.26-0.24 0.44-0.41 0.074-0.065 0.18-0.096 0.32-0.096 0.15 0 0.27 0.04 0.36 0.12 0.091 0.083 0.14 0.2 0.14 0.35 0 0.13-0.051 0.29-0.15 0.47-0.1 0.17-0.26 0.35-0.47 0.51-0.21 0.16-0.47 0.3-0.78 0.41-0.31 0.11-0.67 0.16-1.1 0.16-0.93 0-1.7-0.27-2.2-0.81-0.51-0.54-0.77-1.3-0.77-2.2 0-0.43 0.064-0.84 0.19-1.2 0.13-0.37 0.31-0.69 0.56-0.96 0.24-0.27 0.54-0.47 0.9-0.61 0.36-0.15 0.75-0.22 1.2-0.22 0.56 0 1 0.12 1.5 0.37 0.4 0.24 0.71 0.55 0.91 0.94 0.2 0.38 0.3 0.78 0.3 1.2 0 0.37-0.1 0.61-0.31 0.72-0.21 0.11-0.5 0.16-0.88 0.16zm-2.8-0.84h2.6c-0.036-0.5-0.17-0.88-0.4-1.1-0.23-0.25-0.53-0.38-0.91-0.38-0.36 0-0.66 0.13-0.89 0.38-0.23 0.25-0.37 0.63-0.42 1.1zm-6.3-3.7v2.2c0.18-0.22 0.36-0.39 0.53-0.51 0.18-0.13 0.37-0.22 0.58-0.28 0.21-0.065 0.44-0.096 0.68-0.096 0.37 0 0.69 0.078 0.97 0.24 0.29 0.16 0.51 0.39 0.67 0.69 0.1 0.17 0.17 0.37 0.21 0.59 0.033 0.22 0.052 0.47 0.052 0.75v2.8c0 0.29-0.067 0.52-0.2 0.67-0.13 0.15-0.31 0.23-0.53 0.23-0.48 0-0.71-0.3-0.71-0.9v-2.5c0-0.47-0.07-0.83-0.21-1.1-0.14-0.26-0.4-0.38-0.79-0.38-0.26 0-0.49 0.075-0.7 0.23-0.21 0.15-0.36 0.35-0.46 0.61-0.08 0.22-0.12 0.61-0.12 1.2v1.9c0 0.29-0.065 0.51-0.2 0.67-0.13 0.15-0.31 0.23-0.53 0.23-0.48 0-0.72-0.3-0.72-0.9v-6.4c0-0.3 0.062-0.52 0.19-0.67 0.13-0.15 0.3-0.23 0.53-0.23 0.23 0 0.41 0.076 0.53 0.23 0.13 0.15 0.2 0.37 0.2 0.67zm-2.6 5.5c0 0.18-0.055 0.38-0.17 0.59-0.11 0.21-0.27 0.41-0.49 0.6-0.22 0.19-0.5 0.34-0.83 0.45-0.33 0.11-0.71 0.17-1.1 0.17-0.89 0-1.6-0.26-2.1-0.79-0.5-0.53-0.75-1.2-0.75-2.1 0-0.61 0.11-1.1 0.34-1.6 0.23-0.46 0.56-0.82 1-1.1 0.43-0.25 0.95-0.38 1.6-0.38 0.38 0 0.72 0.054 1 0.17 0.31 0.11 0.58 0.26 0.79 0.43 0.22 0.18 0.39 0.37 0.5 0.57 0.12 0.2 0.18 0.38 0.18 0.56 0 0.18-0.065 0.33-0.2 0.45-0.13 0.12-0.28 0.18-0.47 0.18-0.12 0-0.22-0.029-0.3-0.092-0.078-0.064-0.17-0.17-0.27-0.31-0.18-0.27-0.36-0.48-0.56-0.62-0.19-0.14-0.43-0.21-0.73-0.21-0.43 0-0.77 0.17-1 0.51-0.26 0.34-0.39 0.8-0.39 1.4 0 0.28 0.032 0.53 0.1 0.76 0.067 0.23 0.17 0.43 0.29 0.59 0.13 0.16 0.28 0.29 0.46 0.37 0.18 0.083 0.38 0.12 0.59 0.12 0.29 0 0.54-0.066 0.74-0.2 0.21-0.14 0.39-0.34 0.55-0.63 0.09-0.16 0.19-0.29 0.29-0.39 0.1-0.092 0.23-0.14 0.38-0.14 0.18 0 0.32 0.069 0.44 0.2 0.12 0.14 0.18 0.28 0.18 0.44zm-9.1-4h0.16v-0.89c0-0.24 0.0059-0.42 0.017-0.56 0.013-0.14 0.049-0.25 0.11-0.35 0.055-0.1 0.14-0.18 0.24-0.24 0.11-0.064 0.22-0.096 0.35-0.096 0.18 0 0.35 0.07 0.5 0.21 0.1 0.092 0.16 0.21 0.19 0.34 0.027 0.13 0.042 0.32 0.042 0.57v1h0.53c0.2 0 0.36 0.05 0.47 0.15 0.11 0.096 0.16 0.22 0.16 0.38 0 0.2-0.078 0.34-0.23 0.41-0.15 0.079-0.37 0.12-0.66 0.12h-0.27v2.7c0 0.23 0.0074 0.41 0.022 0.53 0.017 0.12 0.059 0.22 0.13 0.3 0.07 0.076 0.18 0.11 0.34 0.11 0.084 0 0.2-0.011 0.34-0.043 0.14-0.032 0.26-0.047 0.34-0.047 0.12 0 0.22 0.047 0.31 0.15 0.096 0.095 0.14 0.21 0.14 0.35 0 0.24-0.13 0.42-0.38 0.54-0.26 0.13-0.62 0.19-1.1 0.19-0.45 0-0.8-0.078-1-0.23-0.23-0.15-0.39-0.37-0.46-0.64-0.071-0.27-0.11-0.64-0.11-1.1v-2.8h-0.19c-0.21 0-0.37-0.049-0.48-0.15-0.11-0.099-0.16-0.23-0.16-0.38 0-0.16 0.055-0.28 0.17-0.38 0.11-0.1 0.28-0.15 0.5-0.15zm-2.8 5c-0.35 0.28-0.69 0.49-1 0.63-0.33 0.14-0.69 0.2-1.1 0.2-0.37 0-0.7-0.074-0.98-0.22-0.28-0.15-0.5-0.35-0.65-0.61-0.15-0.26-0.23-0.53-0.23-0.83 0-0.4 0.12-0.75 0.38-1 0.25-0.28 0.59-0.47 1-0.57 0.09-0.022 0.32-0.069 0.68-0.14 0.36-0.076 0.67-0.15 0.93-0.21 0.26-0.064 0.54-0.14 0.85-0.23-0.019-0.39-0.096-0.67-0.23-0.85-0.14-0.18-0.42-0.27-0.84-0.27-0.37 0-0.64 0.052-0.83 0.16-0.18 0.1-0.34 0.26-0.48 0.47-0.13 0.21-0.22 0.35-0.28 0.41-0.054 0.065-0.17 0.098-0.35 0.098-0.16 0-0.3-0.052-0.42-0.16-0.12-0.11-0.17-0.25-0.17-0.41 0-0.26 0.088-0.51 0.27-0.76 0.18-0.25 0.46-0.45 0.84-0.6 0.38-0.16 0.86-0.24 1.4-0.24 0.64 0 1.1 0.078 1.5 0.23 0.36 0.15 0.62 0.39 0.77 0.72 0.15 0.33 0.23 0.77 0.23 1.3 0 0.35-0.0029 0.64-0.0059 0.88 0 0.24 0 0.51-0.0045 0.8 0 0.28 0.043 0.57 0.13 0.87 0.091 0.3 0.14 0.49 0.14 0.58 0 0.15-0.072 0.29-0.21 0.42-0.14 0.12-0.3 0.18-0.47 0.18-0.15 0-0.3-0.071-0.44-0.21-0.15-0.14-0.3-0.35-0.46-0.62zm-0.096-2.1c-0.21 0.081-0.52 0.17-0.93 0.26-0.4 0.087-0.68 0.15-0.84 0.19-0.16 0.037-0.3 0.12-0.44 0.24-0.14 0.12-0.21 0.29-0.21 0.5 0 0.22 0.083 0.41 0.25 0.57 0.16 0.15 0.38 0.23 0.65 0.23 0.29 0 0.55-0.063 0.79-0.19 0.24-0.13 0.42-0.3 0.53-0.5 0.13-0.23 0.2-0.59 0.2-1.1v-0.21zm-8.4 0.076v2c0 0.31-0.07 0.54-0.21 0.7-0.14 0.16-0.32 0.23-0.54 0.23-0.22 0-0.4-0.078-0.54-0.23-0.13-0.15-0.2-0.39-0.2-0.7v-2.3c0-0.37-0.013-0.66-0.036-0.86-0.024-0.2-0.093-0.37-0.2-0.5-0.11-0.13-0.28-0.2-0.52-0.2-0.48 0-0.79 0.17-0.94 0.5-0.15 0.33-0.22 0.81-0.22 1.4v2c0 0.3-0.068 0.54-0.21 0.7-0.14 0.16-0.31 0.23-0.54 0.23-0.22 0-0.4-0.078-0.54-0.23-0.14-0.16-0.21-0.39-0.21-0.7v-4.2c0-0.28 0.061-0.49 0.19-0.63 0.13-0.14 0.29-0.22 0.5-0.22 0.2 0 0.36 0.066 0.49 0.2 0.13 0.13 0.2 0.32 0.2 0.56v0.14c0.25-0.3 0.52-0.53 0.81-0.67 0.29-0.14 0.6-0.21 0.95-0.21 0.36 0 0.68 0.074 0.94 0.22 0.26 0.15 0.48 0.37 0.65 0.67 0.24-0.3 0.5-0.52 0.78-0.67 0.28-0.15 0.59-0.22 0.93-0.22 0.39 0 0.74 0.076 1 0.24 0.29 0.16 0.5 0.39 0.64 0.68 0.12 0.27 0.18 0.68 0.18 1.3v2.9c0 0.31-0.068 0.54-0.21 0.69-0.14 0.16-0.32 0.23-0.55 0.23-0.22 0-0.4-0.08-0.54-0.23-0.14-0.16-0.21-0.39-0.21-0.69v-2.5c0-0.32-0.016-0.57-0.042-0.76-0.026-0.19-0.096-0.35-0.21-0.48-0.12-0.13-0.29-0.2-0.53-0.2-0.19 0-0.37 0.059-0.55 0.17-0.17 0.12-0.3 0.27-0.4 0.46-0.1 0.25-0.16 0.69-0.16 1.3zm-12-3h0.17v-0.88c0-0.24 0.0045-0.42 0.016-0.56 0.016-0.14 0.052-0.25 0.11-0.35 0.058-0.1 0.14-0.18 0.25-0.24 0.11-0.065 0.23-0.096 0.37-0.096 0.19 0 0.37 0.071 0.52 0.21 0.1 0.092 0.17 0.21 0.19 0.34 0.03 0.13 0.045 0.32 0.045 0.57v1h0.55c0.21 0 0.38 0.049 0.49 0.15 0.11 0.096 0.17 0.22 0.17 0.38 0 0.2-0.083 0.34-0.24 0.41-0.16 0.081-0.39 0.12-0.69 0.12h-0.28v2.7c0 0.23 0.0074 0.41 0.022 0.53 0.019 0.12 0.062 0.22 0.13 0.3 0.074 0.075 0.19 0.11 0.35 0.11 0.088 0 0.21-0.013 0.36-0.043 0.15-0.032 0.27-0.047 0.35-0.047 0.12 0 0.23 0.047 0.33 0.14 0.1 0.095 0.15 0.21 0.15 0.35 0 0.24-0.13 0.42-0.4 0.54-0.27 0.13-0.65 0.19-1.1 0.19-0.47 0-0.83-0.078-1.1-0.23-0.24-0.15-0.4-0.37-0.48-0.64-0.075-0.27-0.11-0.64-0.11-1.1v-2.8h-0.2c-0.22 0-0.39-0.05-0.5-0.15-0.12-0.099-0.17-0.23-0.17-0.38 0-0.16 0.061-0.28 0.18-0.38 0.12-0.1 0.3-0.15 0.53-0.15zm-5.2-1.4v2.2c0.19-0.22 0.38-0.39 0.56-0.51 0.18-0.13 0.39-0.22 0.61-0.28 0.22-0.063 0.46-0.096 0.71-0.096 0.38 0 0.72 0.078 1 0.24 0.3 0.16 0.53 0.39 0.71 0.69 0.11 0.17 0.18 0.37 0.22 0.59 0.036 0.22 0.054 0.47 0.054 0.75v2.8c0 0.29-0.071 0.52-0.21 0.67-0.14 0.15-0.32 0.23-0.55 0.23-0.5 0-0.75-0.3-0.75-0.89v-2.5c0-0.47-0.071-0.83-0.21-1.1-0.14-0.26-0.42-0.38-0.82-0.38-0.27 0-0.51 0.075-0.73 0.23-0.22 0.15-0.38 0.35-0.48 0.61-0.081 0.22-0.12 0.61-0.12 1.2v1.9c0 0.29-0.068 0.51-0.2 0.67-0.13 0.15-0.32 0.23-0.56 0.23-0.5 0-0.75-0.3-0.75-0.89v-6.4c0-0.3 0.065-0.52 0.19-0.67 0.13-0.15 0.32-0.23 0.55-0.23 0.24 0 0.43 0.076 0.56 0.23 0.14 0.15 0.2 0.37 0.2 0.67zm-2.7 2.4v4.3c0 0.49-0.056 0.91-0.16 1.3-0.11 0.35-0.28 0.64-0.51 0.87-0.24 0.23-0.55 0.4-0.93 0.51-0.38 0.11-0.85 0.17-1.4 0.17-0.52 0-0.99-0.072-1.4-0.22-0.41-0.14-0.72-0.32-0.95-0.55-0.22-0.22-0.33-0.45-0.33-0.69 0-0.18 0.061-0.33 0.19-0.44 0.12-0.11 0.28-0.17 0.45-0.17 0.22 0 0.41 0.095 0.58 0.28 0.083 0.098 0.16 0.2 0.25 0.29 0.088 0.1 0.18 0.19 0.29 0.25 0.11 0.072 0.23 0.12 0.38 0.16 0.15 0.036 0.32 0.055 0.51 0.055 0.39 0 0.69-0.055 0.91-0.16 0.22-0.1 0.37-0.25 0.45-0.44 0.088-0.19 0.14-0.39 0.16-0.61 0.016-0.22 0.026-0.56 0.033-1-0.23 0.32-0.5 0.56-0.81 0.72-0.3 0.17-0.66 0.25-1.1 0.25-0.5 0-0.95-0.13-1.3-0.38-0.38-0.25-0.67-0.6-0.87-1.1-0.2-0.45-0.31-0.97-0.31-1.6 0-0.44 0.064-0.84 0.18-1.2 0.12-0.36 0.3-0.66 0.53-0.9 0.23-0.24 0.49-0.43 0.79-0.55 0.3-0.12 0.63-0.19 0.99-0.19 0.43 0 0.8 0.081 1.1 0.24 0.31 0.16 0.6 0.41 0.87 0.75v-0.2c0-0.25 0.064-0.45 0.19-0.59 0.13-0.14 0.29-0.21 0.5-0.21 0.29 0 0.49 0.092 0.58 0.28 0.094 0.18 0.14 0.45 0.14 0.8zm-4.4 1.9c0 0.59 0.13 1 0.4 1.4 0.27 0.31 0.62 0.46 1 0.46 0.25 0 0.49-0.065 0.71-0.19 0.23-0.13 0.41-0.33 0.55-0.59 0.14-0.27 0.21-0.59 0.21-0.97 0-0.6-0.14-1.1-0.41-1.4-0.27-0.34-0.63-0.5-1.1-0.5-0.43 0-0.78 0.16-1 0.48-0.26 0.32-0.39 0.77-0.39 1.4zm-2.7-2.1v4.3c0 0.29-0.074 0.52-0.22 0.67-0.14 0.15-0.33 0.23-0.55 0.23-0.22 0-0.4-0.079-0.54-0.23-0.14-0.15-0.21-0.38-0.21-0.66v-4.2c0-0.29 0.07-0.51 0.21-0.66 0.14-0.15 0.32-0.22 0.54-0.22 0.22 0 0.4 0.073 0.55 0.22 0.14 0.15 0.22 0.35 0.22 0.61zm-0.75-1.5c-0.21 0-0.39-0.062-0.54-0.19-0.15-0.13-0.22-0.3-0.22-0.53 0-0.21 0.077-0.38 0.23-0.51 0.16-0.14 0.33-0.21 0.54-0.21 0.19 0 0.37 0.06 0.52 0.18 0.15 0.12 0.23 0.3 0.23 0.53 0 0.23-0.075 0.41-0.22 0.53-0.15 0.13-0.32 0.19-0.53 0.19zm-3.2 4h-3c0.0029 0.34 0.071 0.63 0.2 0.88 0.14 0.25 0.32 0.45 0.54 0.58 0.22 0.13 0.47 0.19 0.74 0.19 0.18 0 0.34-0.019 0.49-0.058 0.15-0.043 0.3-0.11 0.44-0.19 0.14-0.091 0.27-0.19 0.39-0.29 0.12-0.099 0.27-0.24 0.46-0.41 0.077-0.064 0.19-0.098 0.33-0.098 0.15 0 0.28 0.042 0.38 0.13 0.094 0.082 0.14 0.2 0.14 0.35 0 0.13-0.054 0.29-0.16 0.47-0.11 0.17-0.27 0.35-0.49 0.51-0.21 0.16-0.49 0.3-0.82 0.4-0.32 0.11-0.7 0.16-1.1 0.16-0.97 0-1.7-0.27-2.3-0.81-0.54-0.54-0.81-1.3-0.81-2.2 0-0.43 0.065-0.84 0.2-1.2 0.13-0.37 0.33-0.69 0.58-0.96 0.26-0.26 0.57-0.47 0.94-0.61 0.37-0.14 0.79-0.21 1.2-0.21 0.59 0 1.1 0.12 1.5 0.37 0.42 0.24 0.74 0.55 0.95 0.94 0.21 0.38 0.31 0.78 0.31 1.2 0 0.37-0.11 0.61-0.33 0.72-0.22 0.11-0.52 0.16-0.92 0.16zm-3-0.84h2.7c-0.039-0.5-0.18-0.88-0.42-1.1-0.24-0.25-0.56-0.38-0.95-0.38-0.38 0-0.69 0.13-0.93 0.38-0.24 0.25-0.39 0.63-0.44 1.1zm-9.5-1.6 0.98 3.3 0.9-3.1c0.096-0.32 0.17-0.54 0.21-0.65 0.048-0.12 0.13-0.23 0.26-0.33 0.13-0.11 0.31-0.16 0.53-0.16 0.22 0 0.4 0.054 0.52 0.16 0.13 0.1 0.22 0.22 0.27 0.35 0.049 0.12 0.12 0.33 0.21 0.64l0.9 3.1 1-3.3c0.067-0.24 0.12-0.41 0.16-0.51 0.04-0.11 0.11-0.2 0.2-0.28 0.094-0.084 0.23-0.12 0.42-0.12 0.18 0 0.34 0.06 0.47 0.18 0.13 0.12 0.2 0.26 0.2 0.43 0 0.15-0.058 0.38-0.17 0.68l-1.2 3.5c-0.11 0.3-0.19 0.51-0.25 0.65-0.061 0.13-0.16 0.25-0.28 0.36-0.13 0.1-0.3 0.16-0.52 0.16-0.23 0-0.41-0.057-0.54-0.17-0.13-0.11-0.23-0.25-0.29-0.41-0.062-0.16-0.13-0.37-0.2-0.63l-0.86-2.9-0.84 2.9c-0.11 0.4-0.23 0.7-0.36 0.91-0.13 0.2-0.36 0.3-0.68 0.3-0.17 0-0.31-0.033-0.42-0.098-0.11-0.063-0.21-0.15-0.29-0.26-0.078-0.12-0.15-0.26-0.21-0.41-0.061-0.16-0.1-0.29-0.14-0.39l-1.2-3.5c-0.12-0.33-0.18-0.56-0.18-0.68 0-0.16 0.064-0.3 0.19-0.43 0.13-0.13 0.29-0.19 0.48-0.19 0.25 0 0.42 0.069 0.51 0.21 0.089 0.14 0.18 0.37 0.28 0.71z" fill="#1a1a1a" stroke="#fff" stroke-linecap="round" stroke-linejoin="bevel" stroke-miterlimit="1" stroke-width=".35" style="paint-order:stroke fill markers">
<path d="m63 90c0 0.29-0.22 0.53-0.5 0.53s-0.5-0.24-0.5-0.53c0-0.29 0.22-0.53 0.5-0.53s0.5 0.24 0.5 0.53zm17-0.99v-0.86c3-0.069 3.8-0.85 3.8-0.85h-8.6s0.81 0.78 3.9 0.85v0.85c-0.13 0.086-0.23 0.21-0.29 0.36h-15c-0.24-0.6-0.8-1-1.4-1h-0.027-0.026c-0.65 0-1.2 0.42-1.4 1h-15c-0.059-0.15-0.16-0.28-0.29-0.36v-0.85c3.1-0.065 3.9-0.85 3.9-0.85h-8.6s0.8 0.78 3.8 0.85v0.86c-0.2 0.15-0.33 0.39-0.33 0.67 0 0.45 0.34 0.82 0.77 0.82 0.23 0 0.44-0.11 0.59-0.29l15 0.36c0.08 0.24 0.21 0.45 0.37 0.62l-0.54 1.3h3.3l-0.54-1.2c0.17-0.18 0.31-0.4 0.39-0.64l15-0.36c0.14 0.18 0.35 0.29 0.59 0.29 0.42 0 0.76-0.37 0.76-0.82-0.0011-0.28-0.13-0.52-0.33-0.67z" fill="#ffb454" stroke-width=".37">
</path></path></path></g>

Efficiently find items by matching weight. If your data is static, you can build the lookup structure (a complete binary tree) at compile time.

You can use any inferred numeric type for the weights. You can have any range for the lookup, by default 0.0 .. 1.0 for floats, and their respective whole spectrum MIN ..= MAX for integers.

As a small example, let’s make red more than twice as likely as green, and that in turn five times as likely as blue.

# extern crate weight_matchers;
# use weight_matchers::{dyn_weights, weights};
# fn rand_f32() -> f32 { 0.0 }
let colours = weights! {
    0.70 => "red",
    0.25 => "green",
    0.05 => "blue",
};

// If you have dynamic values, use this macro instead:
let frequent = 0.70;
let most = "red";
let dyn_colours = dyn_weights! {
    frequent => most,
    0.25 => "green",
    0.05 => "blue",
};
// Any random source of the same type and range as your weights will do.
println!("I got {}", colours.get(rand_f32()));
println!("I got {}", dyn_colours.get(rand_f32()));

There’s a blog about the design choices behind this.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.