yog-script-analyze 0.2.2

Yog Script (.ys, .yns) analyzed: its lexer, parser and syntax tree, names resolved, the class index model — what the build and the editors read a source with.
Documentation
//! A declaration's type parameters and what they must be (`ys-grammar.md`
//! §2.3): `<in T, out R>`, `where T : class, new(), IComparable<T>`.

use super::{Name, Type};

/// `T`, `in T`, `out T`, or a lifetime `'a`.
#[derive(Debug, Clone, PartialEq)]
pub struct Generic {
    pub name: Name,
    pub variance: Option<Variance>,
    /// `'a`: a lifetime, not a type.
    pub lifetime: bool,
}

/// An interface's or a delegate's type parameter: taken (`in`) or given
/// (`out`).
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Variance {
    In,
    Out,
}

/// One thing a type parameter must be.
#[derive(Debug, Clone, PartialEq)]
pub enum Constraint {
    /// `class`: an object (a reference).
    Class,
    /// `struct`: a value.
    Struct,
    /// `new()`: made with no arguments.
    New,
    /// A base class or an interface.
    Type(Type),
}

/// `where T : …`.
#[derive(Debug, Clone, PartialEq)]
pub struct Where {
    pub name: Name,
    pub bounds: Vec<Constraint>,
}