mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-04-23 08:07:38 +02:00
Put tinyvec example inline.
This commit is contained in:
parent
fb3fd3979c
commit
f5b6e47f31
7
Cargo.lock
generated
7
Cargo.lock
generated
@ -2068,13 +2068,6 @@ dependencies = [
|
|||||||
"tinyvec_macros",
|
"tinyvec_macros",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "tinyvec-example"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"tinyvec",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tinyvec_macros"
|
name = "tinyvec_macros"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -3,6 +3,5 @@ members = [
|
|||||||
"i18n-helpers",
|
"i18n-helpers",
|
||||||
"src/exercises",
|
"src/exercises",
|
||||||
"src/bare-metal/useful-crates/allocator-example",
|
"src/bare-metal/useful-crates/allocator-example",
|
||||||
"src/bare-metal/useful-crates/tinyvec-example",
|
|
||||||
"src/bare-metal/useful-crates/zerocopy-example",
|
"src/bare-metal/useful-crates/zerocopy-example",
|
||||||
]
|
]
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "tinyvec-example"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
tinyvec = "1.6.0"
|
|
@ -1,25 +0,0 @@
|
|||||||
// Copyright 2023 Google LLC
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
// ANCHOR: main
|
|
||||||
use tinyvec::{array_vec, ArrayVec};
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let mut numbers: ArrayVec<[u32; 5]> = array_vec!(42, 66);
|
|
||||||
println!("{numbers:?}");
|
|
||||||
numbers.push(7);
|
|
||||||
println!("{numbers:?}");
|
|
||||||
numbers.remove(1);
|
|
||||||
println!("{numbers:?}");
|
|
||||||
}
|
|
@ -6,7 +6,16 @@ allocated or on the stack, which keeps track of how many elements are used and p
|
|||||||
use more than are allocated.
|
use more than are allocated.
|
||||||
|
|
||||||
```rust,editable,compile_fail
|
```rust,editable,compile_fail
|
||||||
{{#include tinyvec-example/src/main.rs:main}}
|
use tinyvec::{array_vec, ArrayVec};
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let mut numbers: ArrayVec<[u32; 5]> = array_vec!(42, 66);
|
||||||
|
println!("{numbers:?}");
|
||||||
|
numbers.push(7);
|
||||||
|
println!("{numbers:?}");
|
||||||
|
numbers.remove(1);
|
||||||
|
println!("{numbers:?}");
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user