10000 rune: Move item into own module · rune-rs/rune@95925d0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 95925d0

Browse files
committed
rune: Move item into own module
1 parent 71aa2f1 commit 95925d0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+153
-139
lines changed

crates/rune-core/src/hash/to_type_hash.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ use core::hash::{self, Hash as _, Hasher as _};
22

33
#[cfg(feature = "alloc")]
44
use crate::alloc;
5-
use crate::hash::{Hash, TYPE};
5+
use crate::hash::Hash;
6+
use crate::hash::TYPE;
67
use crate::item::{IntoComponent, ItemBuf};
78

89
/// Helper trait used to convert a type into a type hash.

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

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ impl Item {
2424
/// # Examples
2525
///
2626
/// ```
27-
/// use rune::compile::{Item, ItemBuf};
27+
/// use rune::{Item, ItemBuf};
2828
///
2929
/// assert_eq!(Item::new(), &*ItemBuf::new());
3030
/// ```
@@ -44,7 +44,7 @@ impl Item {
4444
/// # Examples
4545
///
4646
/// ```
47-
/// use rune::compile::{Item, ItemBuf};
47+
/// use rune::{Item, ItemBuf};
4848
///
4949
/// let item = ItemBuf::with_item(["foo", "bar"])?;
5050
///
@@ -61,7 +61,7 @@ impl Item {
6161
/// # Examples
6262
///
6363
/// ```
64-
/// use rune::compile::{Item, ItemBuf};
64+
/// use rune::{Item, ItemBuf};
6565
///
6666
/// assert_eq!(Item::new().as_bytes(), b"");
6767
///
@@ -79,7 +79,7 @@ impl Item {
7979
/// # Examples
8080
///
8181
/// ```
82-
/// use rune::compile::ItemBuf;
82+
/// use rune::ItemBuf;
8383
///
8484
/// let item = ItemBuf::with_crate("std")?;
8585
/// assert_eq!(item.as_crate(), Some("std"));
@@ -101,7 +101,8 @@ impl Item {
101101
/// # Examples
102102
///
103103
/// ```
104-
/// use rune::compile::{ComponentRef, ItemBuf};
104+
/// use rune::ItemBuf;
105+
/// use rune::item::ComponentRef;
105106
///
106107
/// let item = ItemBuf::with_item(["foo", "bar"])?;
107108
/// assert_eq!(item.first(), Some(ComponentRef::Str("foo")));
@@ -117,7 +118,7 @@ impl Item {
117118
/// # Examples
118119
///
119120
/// ```
120-
/// use rune::compile::ItemBuf;
121+
/// use rune::ItemBuf;
121122
///
122123
/// let item = ItemBuf::new();
123124
/// assert!(item.is_empty());
@@ -154,7 +155,8 @@ impl Item {
154155
/// # Examples
155156
///
156157
/// ```
157-
/// use rune::compile::{Item, ComponentRef};
158+
/// use rune::Item;
159+
/// use rune::item::ComponentRef;
158160
///
159161
/// let item = Item::new();
160162
/// assert!(item.is_empty());
@@ -185,7 +187,8 @@ impl Item {
185187
/// # Examples
186188
///
187189
/// ```
188-
/// use rune::compile::{Item, ComponentRef};
190+
/// use rune::Item;
191+
/// use rune::item::ComponentRef;
189192
///
190193
/// let item = Item::new();
191194
/// assert!(item.is_empty());
@@ -217,7 +220,8 @@ impl Item {
217220
/// # Examples
218221
///
219222
/// ```
220-
/// use rune::compile::{ComponentRef, IntoComponent, ItemBuf};
223+
/// use rune::ItemBuf;
224+
/// use rune::item::{ComponentRef, IntoComponent};
221225
///
222226
/// let mut item = ItemBuf::new();
223227
///
@@ -260,7 +264,7 @@ impl Item {
260264
/// # Examples
261265
///
262266
/// ```
263-
/// use rune::compile::{Item, ItemBuf};
267+
/// use rune::{Item, ItemBuf};
264268
///
265269
/// assert!(Item::new().is_super_of(Item::new(), 1));
266270
/// assert!(!ItemBuf::with_item(["a"])?.is_super_of(Item::new(), 1));
@@ -304,7 +308,7 @@ impl Item {
304308
/// # Examples
305309
///
306310
/// ```
307-
/// use rune::compile::{Item, ItemBuf};
311+
/// use rune::{Item, ItemBuf};
308312
///
309313
/// assert_eq!(
310314
/// (ItemBuf::new(), ItemBuf::new()),
@@ -368,7 +372,7 @@ impl Item {
368372
/// # Examples
369373
///
370374
/// ```
371-
/// use rune::compile::ItemBuf;
375+
/// use rune::ItemBuf;
372376
///
373377
/// let item = ItemBuf::with_item(["foo", "bar", "baz"])?;
374378
/// let item2 = ItemBuf::with_item(["foo", "bar"])?;
@@ -416,8 +420,9 @@ impl TryToOwned for Item {
416420
/// # Examples
417421
///
418422
/// ```
419-
/// use rune::compile::{ComponentRef, ItemBuf};
420423
/// use rune::alloc::prelude::*;
424+
/// use rune::ItemBuf;
425+
/// use rune::item::ComponentRef;
421426
///
422427
/// let root = ItemBuf::new().try_to_string()?;
423428
/// assert_eq!("{root}", root);

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ impl ItemBuf {
155155
/// # Examples
156156
///
157157
/// ```
158-
/// use rune::compile::ItemBuf;
158+
/// use rune::ItemBuf;
159159
///
160160
/// let item = ItemBuf::new();
161161
/// let mut it = item.iter();
@@ -173,7 +173,8 @@ impl ItemBuf {
173173
/// # Examples
174174
///
175175
/// ```
176-
/// use rune::compile::{ComponentRef, ItemBuf};
176+
/// use rune::ItemBuf;
177+
/// use rune::item::ComponentRef;
177178
///
178179
/// let item = ItemBuf::with_item(["foo", "bar"])?;
179180
/// let mut it = item.iter();
@@ -196,7 +197,8 @@ impl ItemBuf {
196197
/// # Examples
197198
///
198199
/// ```
199-
/// use rune::compile::{ComponentRef, ItemBuf};
200+
/// use rune::ItemBuf;
201+
/// use rune::item::ComponentRef;
200202
///
201203
/// let mut item = ItemBuf::with_crate("std")?;
202204
/// item.push("foo");
@@ -217,7 +219,8 @@ impl ItemBuf {
217219
/// # Examples
218220
///
219221
/// ```
220-
/// use rune::compile::{ComponentRef, ItemBuf};
222+
/// use rune::ItemBuf;
223+
/// use rune::item::ComponentRef;
221224
///
222225
/// let item = ItemBuf::with_crate_item("std", ["option"])?;
223226
/// assert_eq!(item.as_crate(), Some("std"));

crates/rune-core/src/lib.rs

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,8 @@ extern crate std as rust_std;
3737
extern crate alloc as rust_alloc;
3838

3939
pub use rune_alloc as alloc;
40-
41-
mod hash;
42-
#[doc(hidden)]
43-
pub use hash::ParametersBuilder;
44-
pub use hash::{Hash, IntoHash, ToTypeHash};
45-
46-
mod item;
47-
#[cfg(feature = "alloc")]
48-
pub use self::item::Component;
49-
pub use self::item::{ComponentRef, IntoComponent, Item, ItemBuf};
50-
51-
mod raw_str;
52-
pub use self::raw_str::RawStr;
53-
54-
mod protocol;
55-
pub use self::protocol::Protocol;
56-
57-
mod params;
58-
pub use self::params::Params;
40+
pub mod hash;
41+
pub mod item;
42+
pub mod params;
43+
pub mod protocol;
44+
pub mod raw_str;

crates/rune-macros/src/any.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::collections::BTreeMap;
22

33
use proc_macro2::TokenStream;
44
use quote::{quote, quote_spanned, ToTokens};
5-
use rune_core::Hash;
5+
use rune_core::hash::Hash;
66
use syn::punctuated::Punctuated;
77
use syn::spanned::Spanned;
88
use syn::Token;

crates/rune-macros/src/hash.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use core::mem::take;
22

3-
use rune_core::{ComponentRef, Hash, ItemBuf};
3+
use rune_core::hash::Hash;
4+
use rune_core::item::{ComponentRef, ItemBuf};
45

56
/// Construct a type hash from a Rust path.
67
pub(crate) fn build_type_hash(path: &syn::Path) -> syn::Result<Hash> {

crates/rune-macros/src/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use core::mem::take;
22

33
use proc_macro2::Span;
4-
use rune_core::{ComponentRef, ItemBuf};
4+
use rune_core::item::{ComponentRef, ItemBuf};
55

66
/// Construct a static item from a path.
77
pub(crate) fn build_item(path: &syn::Path) -> syn::Result<syn::ExprArray> {

crates/rune-shim/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
pub use rune_alloc as alloc;
33

44
#[cfg(feature = "rune-core")]
5-
pub mod compile {
6-
pub use rune_core::{Component, ComponentRef, IntoComponent, Item, ItemBuf};
5+
pub mod item {
6+
pub use rune_core::item::{Component, ComponentRef, IntoComponent, Item, ItemBuf};
77
}
88

99
pub mod support {
@@ -12,4 +12,4 @@ pub mod support {
1212
}
1313

1414
#[cfg(feature = "rune-core")]
15-
pub use rune_core::{Item, ItemBuf};
15+
pub use rune_core::item::{Item, ItemBuf};

crates/rune/src/build.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::compile::NoopSourceLoader as DefaultSourceLoader;
1212
use crate::compile::{CompileVisitor, Located, MetaError, Options, Pool, SourceLoader};
1313
use crate::runtime::unit::{DefaultStorage, UnitEncoder};
1414
use crate::runtime::Unit;
15-
use crate::{Context, Diagnostics, SourceId, Sources};
15+
use crate::{Context, Diagnostics, Item, SourceId, Sources};
1616

1717
/// Error raised when we failed to load sources.
1818
///
@@ -185,7 +185,7 @@ impl<'a> compile::CompileVisitor for CompileVisitorGroup<'a> {
185185
fn visit_doc_comment(
186186
&mut self,
187187
location: &dyn Located,
188-
item: &compile::Item,
188+
item: &Item,
189189
hash: crate::Hash,
190190
doc: &str,
191191
) -> Result<(), MetaError> {
@@ -199,7 +199,7 @@ impl<'a> compile::CompileVisitor for CompileVisitorGroup<'a> {
199199
fn visit_field_doc_comment(
200200
&mut self,
201201
location: &dyn Located,
202-
item: &compile::Item,
202+
item: &Item,
203203
hash: crate::Hash,
204204
field: &str,
205205
doc: &str,

crates/rune/src/cli/benches.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ use std::time::Instant;
66

77
use crate::alloc::Vec;
88
use crate::cli::{AssetKind, CommandBase, Config, ExitCode, Io, SharedFlags};
9-
use crate::compile::{Item, ItemBuf};
109
use crate::modules::capture_io::CaptureIo;
1110
use crate::modules::test::Bencher;
1211
use crate::runtime::{Function, Unit, Value};
1312
use crate::support::Result;
14-
use crate::{Context, Hash, Sources, Vm};
13+
use crate::{Context, Hash, Item, ItemBuf, Sources, Vm};
1514

1615
mod cli {
1716
use std::path::PathBuf;

0 commit comments

Comments
 (0)
0