我有一个像这样的数组:
let array = [14, 42, 1, 3]
Run Code Online (Sandbox Code Playgroud)
我想获取映射到此的数组编号:
[1, 0, 3, 2]
Run Code Online (Sandbox Code Playgroud)
原因如下:
1
:因为14
是第二大数字0
:因为42
数量最多3
:...到目前为止我尝试过的是:
let array = [14, 42, 1, 3]
Run Code Online (Sandbox Code Playgroud)
假设我们在 SQLite 中有下表和查询:
\nID | 瓦尔 | 家长 | 信 |
---|---|---|---|
1 | 3 | 10 | A |
2 | 3 | 10 | 乙 |
3 | 0 | 10 | C |
4 | 5 | 20 | d |
SELECT id, MAX(val), parent, letter FROM table GROUP BY parent\n
Run Code Online (Sandbox Code Playgroud)\n的价值有任何保证吗id
?在 MySQL 中甚至有一种模式禁止选择非聚合值。如果没有这样的保证,是否有可能以某种方式获得每行parent
?
ID | 最大值(值) | 家长 | 信 |
---|---|---|---|
1\xe2\x80\xa0 | 3 | 10 | A |
4 | 5 | 20 | d |
letter
\xe2\x80\xa0 或 2(只要来自同一行就没关系)
我想用 flex 用 CSS 创建类似的东西:
到目前为止我尝试过的是这段代码:
#dot-container {
position: absolute;
width: 30vw;
background: black;
height: 8vw;
justify-content: center;
align-items: center;
display: flex;
}
.dot {
border-radius: 100%;
width: 2vw;
height: 2vw;
margin: 3.2%; /*(30-2*7) / (7-2)*/
background: green;
}
Run Code Online (Sandbox Code Playgroud)
<div id="dot-container">
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
但我无法真正让它工作,以至于最左边和最右边的点正好在左边和右边的角落,就像你在我上面的图片中看到的那样。
注意:justify-content: space-between;
似乎也不起作用,因为点本身最左边但不是点中心!
我想将一个引用的元组(所有引用都指向同一结构的成员)转换为一个元组的引用。
我试图以各种方式强迫他们,但是如果没有克隆,我是无法做到的。
struct Bar();
struct Foo(Bar, Bar, Bar);
fn main() {
let a: &Foo = &Foo(Bar(), Bar(), Bar());
let b: &(Bar, Bar) = &(a.0, a.1);
}
Run Code Online (Sandbox Code Playgroud)
error[E0507]: cannot move out of borrowed content
--> src/main.rs:7:28
|
7 | let b: &(Bar, Bar) = &(a.0, a.1);
| ^^^ cannot move out of borrowed content
error[E0507]: cannot move out of borrowed content
--> src/main.rs:7:33
|
7 | let b: &(Bar, Bar) = &(a.0, a.1);
| ^^^ cannot move out of borrowed content …
Run Code Online (Sandbox Code Playgroud)