// The System library's core, as every source sees it (`ys.md` §3, The
// System library): declarations only — what runs is the host's or the
// runtime's.
namespace System;
/// The base of every attribute: `[Name(…)]` on a declaration is an object
/// of a class inheriting it, read by Reflection at run time and by macros
/// at build time.
public abstract class Attribute {}
/// Where an attribute may stand.
public enum AttributeTargets { Class, Struct, Enum, Interface, Method, Property, Field, Parameter, ReturnValue, Module, All }
/// Where the attribute class it marks may stand.
public sealed class AttributeUsage(AttributeTargets on) : Attribute {
public bool AllowMultiple;
public bool Inherited;
}
/// A declaration not to use any more, and what to use instead.
public sealed class Obsolete(string message) : Attribute {}
/// Marks an attribute class as an attribute macro: where it stands, the
/// build runs its `Expand` on the declaration.
public sealed class Macro : Attribute {}
/// Derive macros run on the type it marks: `[Derive(Clone, Equals)]`.
public sealed class Derive : Attribute {}
/// A failure's description: what `Err` carries unless a method says otherwise.
public class Error(string message) {
public string Message = message;
}
/// What may fail: a value, or why it isn't there — Rust's `Result`.
/// `try F()` gives the value or returns the `Err` from the caller.
public enum Result<T, TError> {
Ok(T Value),
Err(TError Error);
public readonly bool IsOk();
public readonly bool IsErr();
/// The value; a panic when it's an `Err`.
public readonly T Unwrap();
/// The value; a panic with `message` when it's an `Err`.
public readonly T Expect(string message);
/// The value, or `fallback` when it's an `Err`.
public readonly T UnwrapOr(T fallback);
}
/// Numbers' functions.
public static class Math {
public static i32 Max(i32 a, i32 b);
public static i32 Min(i32 a, i32 b);
public static i32 Abs(i32 x);
public static i32 Clamp(i32 x, i32 min, i32 max);
public static f64 Sqrt(f64 x);
public static f64 Floor(f64 x);
public static f64 Round(f64 x);
}