• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

vcfxb / wright-lang / 15061769677

16 May 2025 06:02AM UTC coverage: 75.523% (+0.7%) from 74.809%
15061769677

push

github

vcfxb
chore: cargo fmt

6 of 13 new or added lines in 4 files covered. (46.15%)

27 existing lines in 2 files now uncovered.

938 of 1242 relevant lines covered (75.52%)

29.83 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

86.67
/wright/src/ast/ty.rs
1
//! AST models for type signatures in wright source.
2

3
use crate::source_tracking::fragment::Fragment;
4

5
/// A type signature in source code.
6
#[derive(Debug, Clone)]
7
#[allow(missing_docs)]
8
pub enum Type {
9
    Atomic(AtomicTy),
10
    Reference(ReferenceTy),
11
}
12

13
impl Type {
14
    /// Get the matching source for this type signature in source code.
15
    pub fn matching_source(&self) -> &Fragment {
3✔
16
        match self {
3✔
17
            Type::Atomic(atomic_ty) => &atomic_ty.matching_source,
2✔
18
            Type::Reference(reference_ty) => &reference_ty.matching_source,
1✔
19
        }
20
    }
3✔
21

22
    /// Attempt to "downcast" this to an atomic type signature if it is one.
23
    pub fn downcast_primitive(&self) -> Option<&AtomicTy> {
1✔
24
        match self {
1✔
25
            Type::Atomic(atomic) => Some(atomic),
1✔
NEW
26
            _ => None,
×
27
        }
28
    }
1✔
29

30
    /// Attempt to "downcast" this to a reference type signature if it is one.
31
    pub fn downcast_reference(&self) -> Option<&ReferenceTy> {
1✔
32
        match self {
1✔
33
            Type::Reference(reference) => Some(reference),
1✔
NEW
34
            _ => None,
×
35
        }
36
    }
1✔
37
}
38

39
/// The atomic types of wright -- primitive numeric types, boolean, char, etc.
40
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41
#[allow(missing_docs)]
42
pub enum AtomicTyVariant {
43
    Bool,
44
    U8,
45
    I8,
46
    U16,
47
    I16,
48
    U32,
49
    I32,
50
    U64,
51
    I64,
52
    F32,
53
    F64,
54
    Char,
55
}
56

57
/// An atomic type signature in wright source code.
58
#[derive(Clone, Debug)]
59
#[allow(missing_docs)]
60
pub struct AtomicTy {
61
    pub variant: AtomicTyVariant,
62
    pub matching_source: Fragment,
63
}
64

65
/// Source code for a reference type signature, such as `@u64`.
66
#[derive(Debug, Clone)]
67
pub struct ReferenceTy {
68
    /// The source code of the target type.
69
    pub target_ty: Box<Type>,
70
    /// The fragment of the whole reference.
71
    pub matching_source: Fragment,
72
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc