Skip to content

Commit df9ca48

Browse files
committed
Include more things in the alloc prelude
1 parent c8039ea commit df9ca48

File tree

24 files changed

+21
-31
lines changed

24 files changed

+21
-31
lines changed

book/src/sandboxing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ Memory limiting is performed using the [`with` function] in the
2929
`rune::alloc::limit` module.
3030

3131
```rust
32+
use rune::alloc::prelude::*;
3233
use rune::alloc::limit;
33-
use rune::alloc::Vec;
3434

3535
let f = limit::with(1024, || {
3636
let mut vec = Vec::<u32>::try_with_capacity(256)?;

crates/rune-alloc/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,15 @@ pub mod callable;
138138
pub mod prelude {
139139
//! Prelude for common traits used in combination with this crate which
140140
//! matches the behavior of the std prelude.
141+
141142
pub use crate::borrow::TryToOwned;
143+
pub use crate::boxed::Box;
142144
pub use crate::clone::{TryClone, TryCopy};
143145
pub use crate::iter::{IteratorExt, TryExtend, TryFromIterator, TryFromIteratorIn};
144146
pub use crate::option::OptionExt;
145-
pub use crate::string::TryToString;
147+
pub use crate::string::{String, TryToString};
146148
pub use crate::vec::Vec;
149+
pub use crate::{try_format, try_vec};
147150
}
148151

149152
pub mod limit;

crates/rune-core/src/item/component.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
use core::fmt;
22

3-
use crate::alloc::Box;
4-
53
use serde::{Deserialize, Serialize};
64

75
use crate::alloc;
8-
use crate::alloc::clone::TryClone;
6+
use crate::alloc::prelude::*;
97
use crate::item::ComponentRef;
108

119
/// The component of an item.

crates/rune/src/ast/prelude.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//! Prelude for ast elements.
22
33
pub(crate) use crate as rune;
4+
pub(crate) use crate::alloc;
45
pub(crate) use crate::alloc::prelude::*;
5-
pub(crate) use crate::alloc::{self, try_vec, Box, String, Vec};
66
pub(crate) use crate::ast;
77
pub(crate) use crate::ast::{OptionSpanned, Span, Spanned};
88
pub(crate) use crate::compile::{self, ErrorKind};

crates/rune/src/cli/doc.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use anyhow::{Context, Result};
77
use clap::Parser;
88

99
use crate::alloc::prelude::*;
10-
use crate::alloc::Vec;
1110
use crate::cli::naming::Naming;
1211
use crate::cli::{AssetKind, CommandBase, Config, Entry, EntryPoint, ExitCode, Io, SharedFlags};
1312
use crate::compile::{FileSourceLoader, ItemBuf};

crates/rune/src/cli/tests.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use std::time::Instant;
55
use anyhow::{bail, Context, Result};
66

77
use crate::alloc::prelude::*;
8-
use crate::alloc::Vec;
98
use crate::cli::naming::Naming;
109
use crate::cli::visitor;
1110
use crate::cli::{

crates/rune/src/cli/visitor.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use crate::alloc::prelude::*;
2-
use crate::alloc::Vec;
32
use crate::compile::meta;
43
use crate::compile::{CompileVisitor, ItemBuf, MetaError, MetaRef};
54
use crate::Hash;

crates/rune/src/compile/assembly.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use crate as rune;
66
use crate::alloc::fmt::TryWrite;
77
use crate::alloc::prelude::*;
88
use crate::alloc::{hash_map, HashMap};
9-
use crate::alloc::{try_vec, String, Vec};
109
use crate::ast::{Span, Spanned};
1110
use crate::compile::{self, Location};
1211
use crate::runtime::{Inst, Label};

crates/rune/src/compile/compile.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
use crate::alloc;
12
use crate::alloc::prelude::*;
2-
use crate::alloc::{self, try_vec, Box, Vec};
33
use crate::ast;
44
use crate::ast::{Span, Spanned};
55
use crate::compile::v1;

crates/rune/src/compile/ir/scopes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::alloc::prelude::*;
2-
use crate::alloc::{self, try_vec, Box, HashMap, Vec};
2+
use crate::alloc::{self, HashMap};
33
use crate::ast::Spanned;
44
use crate::compile::{self, ErrorKind};
55
use crate::hir;

0 commit comments

Comments
 (0)