mirror of
https://github.com/krahets/hello-algo.git
synced 2024-12-26 21:36:29 +08:00
21 lines
527 B
Rust
21 lines
527 B
Rust
|
/*
|
||
|
* File: vertex.rs
|
||
|
* Created Time: 2023-07-13
|
||
|
* Author: night-cruise (2586447362@qq.com)
|
||
|
*/
|
||
|
|
||
|
/* 頂點型別 */
|
||
|
#[derive(Copy, Clone, Hash, PartialEq, Eq)]
|
||
|
pub struct Vertex {
|
||
|
pub val: i32
|
||
|
}
|
||
|
|
||
|
/* 輸入值串列 vals ,返回頂點串列 vets */
|
||
|
pub fn vals_to_vets(vals: Vec<i32>) -> Vec<Vertex> {
|
||
|
vals.into_iter().map(|val| Vertex { val }).collect()
|
||
|
}
|
||
|
|
||
|
/* 輸入頂點串列 vets ,返回值串列 vals */
|
||
|
pub fn vets_to_vals(vets: Vec<Vertex>) -> Vec<i32> {
|
||
|
vets.into_iter().map(|vet| vet.val).collect()
|
||
|
}
|