mirror of
https://github.com/typst/typst
synced 2025-08-17 08:28:33 +08:00
Improve clarity on type
documentation
- Remove confusing example - Don't refer to `none` and `auto` as "special", they simply do not have a bound name - Be more clear when referencing $content.func
This commit is contained in:
parent
b71abc415a
commit
d92a72d976
@ -45,21 +45,16 @@ use crate::foundations::{
|
|||||||
/// #type(type)
|
/// #type(type)
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// [none]($none) and [auto]($auto) are more special. Because they are the only
|
/// [none]($none) and [auto]($auto) do not have a name representing them like other types such as
|
||||||
/// values of their type, their type isn't actually bound to any name.
|
/// `int`. To test a value to see if it is either of these, compare your value to them directly,
|
||||||
/// ```example
|
/// eg:
|
||||||
/// type(none) == none: #{ type(none) == none } \
|
|
||||||
/// type(auto) == auto: #{ type(auto) == auto }
|
|
||||||
/// ```
|
|
||||||
/// Instead, to test for these _values_, compare to them directly:
|
|
||||||
/// ```example
|
/// ```example
|
||||||
/// #let empty = none
|
/// #let empty = none
|
||||||
/// empty is none: #{ empty == none }
|
/// empty is none: #{ empty == none }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// Note that `type` is used for "high level" comparisons, such as whether a variable is `content`
|
/// Note that `type` is used to test for a variables type. To programmatically determine which
|
||||||
/// vs `int`. See [func]($content.func) to programmatically determine which _element_ a variable
|
/// _element_ a variable is, see [func]($content.func)
|
||||||
/// is.
|
|
||||||
#[ty(scope, cast)]
|
#[ty(scope, cast)]
|
||||||
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
|
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
|
||||||
pub struct Type(Static<NativeTypeData>);
|
pub struct Type(Static<NativeTypeData>);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user