Struct janetrs::JanetSymbol
source · pub struct JanetSymbol<'data> { /* private fields */ }
Expand description
Janet symbol type. Usually used to name things in Janet.
Implementations§
source§impl JanetSymbol<'_>
impl JanetSymbol<'_>
sourcepub fn new(name: impl AsRef<[u8]>) -> Self
pub fn new(name: impl AsRef<[u8]>) -> Self
Create a JanetSymbol
with given name
.
If the given name
is bigger than i32::MAX
the generated symbol will have a
name truncated to that max size. That’s unrealistic thought.
§Examples
use janetrs::JanetSymbol;
let s = JanetSymbol::new("name");
sourcepub fn unique() -> Self
pub fn unique() -> Self
Generate a unique Janet symbol. This is used in the library function gensym. The symbol will be of the format _XXXXXX, where X is a base64 digit, and prefix is the argument passed. No prefix for speed.
§Examples
use janetrs::JanetSymbol;
let s = JanetSymbol::unique();
sourcepub const unsafe fn from_raw(raw: *const u8) -> Self
pub const unsafe fn from_raw(raw: *const u8) -> Self
Create a new JanetSymbol
with a raw
pointer.
§Safety
This function do not check if the given raw
is NULL
or not. Use at your
own risk.
sourcepub fn len(&self) -> i32
pub fn len(&self) -> i32
Returns the length of this JanetSymbol
, in bytes, not char
s or graphemes.
In other words, it may not be what a human considers the length of the string.
§Examples
use janetrs::JanetSymbol;
let s = JanetSymbol::new("name");
assert_eq!(s.len(), 4);
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true
if this JanetSymbol
has a length of zero, and false
otherwise.
§Examples
use janetrs::JanetSymbol;
let s = JanetSymbol::new("name");
assert!(!s.is_empty());
Trait Implementations§
source§impl AsRef<[u8]> for JanetSymbol<'_>
impl AsRef<[u8]> for JanetSymbol<'_>
source§impl AsRef<BStr> for JanetSymbol<'_>
impl AsRef<BStr> for JanetSymbol<'_>
source§impl Clone for JanetSymbol<'_>
impl Clone for JanetSymbol<'_>
source§impl Debug for JanetSymbol<'_>
impl Debug for JanetSymbol<'_>
source§impl Display for JanetSymbol<'_>
impl Display for JanetSymbol<'_>
source§impl From<&[u8]> for JanetSymbol<'_>
impl From<&[u8]> for JanetSymbol<'_>
source§impl From<&JanetBuffer<'_>> for JanetSymbol<'_>
impl From<&JanetBuffer<'_>> for JanetSymbol<'_>
source§fn from(buff: &JanetBuffer<'_>) -> Self
fn from(buff: &JanetBuffer<'_>) -> Self
source§impl From<&JanetKeyword<'_>> for JanetSymbol<'_>
impl From<&JanetKeyword<'_>> for JanetSymbol<'_>
source§fn from(key: &JanetKeyword<'_>) -> Self
fn from(key: &JanetKeyword<'_>) -> Self
source§impl From<&JanetString<'_>> for JanetSymbol<'_>
impl From<&JanetString<'_>> for JanetSymbol<'_>
source§fn from(string: &JanetString<'_>) -> Self
fn from(string: &JanetString<'_>) -> Self
source§impl From<&JanetSymbol<'_>> for Janet
impl From<&JanetSymbol<'_>> for Janet
source§fn from(val: &JanetSymbol<'_>) -> Self
fn from(val: &JanetSymbol<'_>) -> Self
source§impl From<&JanetSymbol<'_>> for JanetBuffer<'_>
impl From<&JanetSymbol<'_>> for JanetBuffer<'_>
source§fn from(s: &JanetSymbol<'_>) -> Self
fn from(s: &JanetSymbol<'_>) -> Self
source§impl From<&JanetSymbol<'_>> for JanetKeyword<'_>
impl From<&JanetSymbol<'_>> for JanetKeyword<'_>
source§fn from(sym: &JanetSymbol<'_>) -> Self
fn from(sym: &JanetSymbol<'_>) -> Self
source§impl From<&JanetSymbol<'_>> for JanetString<'_>
impl From<&JanetSymbol<'_>> for JanetString<'_>
source§fn from(sym: &JanetSymbol<'_>) -> Self
fn from(sym: &JanetSymbol<'_>) -> Self
source§impl From<&str> for JanetSymbol<'_>
impl From<&str> for JanetSymbol<'_>
source§impl From<JanetBuffer<'_>> for JanetSymbol<'_>
impl From<JanetBuffer<'_>> for JanetSymbol<'_>
source§fn from(buff: JanetBuffer<'_>) -> Self
fn from(buff: JanetBuffer<'_>) -> Self
source§impl From<JanetKeyword<'_>> for JanetSymbol<'_>
impl From<JanetKeyword<'_>> for JanetSymbol<'_>
source§fn from(key: JanetKeyword<'_>) -> Self
fn from(key: JanetKeyword<'_>) -> Self
source§impl From<JanetString<'_>> for JanetSymbol<'_>
impl From<JanetString<'_>> for JanetSymbol<'_>
source§fn from(string: JanetString<'_>) -> Self
fn from(string: JanetString<'_>) -> Self
source§impl From<JanetSymbol<'_>> for Janet
impl From<JanetSymbol<'_>> for Janet
source§fn from(val: JanetSymbol<'_>) -> Self
fn from(val: JanetSymbol<'_>) -> Self
source§impl From<JanetSymbol<'_>> for JanetBuffer<'_>
impl From<JanetSymbol<'_>> for JanetBuffer<'_>
source§fn from(s: JanetSymbol<'_>) -> Self
fn from(s: JanetSymbol<'_>) -> Self
source§impl From<JanetSymbol<'_>> for JanetKeyword<'_>
impl From<JanetSymbol<'_>> for JanetKeyword<'_>
source§fn from(sym: JanetSymbol<'_>) -> Self
fn from(sym: JanetSymbol<'_>) -> Self
source§impl From<JanetSymbol<'_>> for JanetString<'_>
impl From<JanetSymbol<'_>> for JanetString<'_>
source§fn from(sym: JanetSymbol<'_>) -> Self
fn from(sym: JanetSymbol<'_>) -> Self
source§impl From<String> for JanetSymbol<'_>
impl From<String> for JanetSymbol<'_>
source§impl FromStr for JanetSymbol<'_>
impl FromStr for JanetSymbol<'_>
source§impl JanetTypeName for JanetSymbol<'_>
impl JanetTypeName for JanetSymbol<'_>
source§impl Ord for JanetSymbol<'_>
impl Ord for JanetSymbol<'_>
source§impl<'a, 'b> PartialEq<&'a [u8]> for JanetSymbol<'_>
impl<'a, 'b> PartialEq<&'a [u8]> for JanetSymbol<'_>
source§impl<'a, 'b> PartialEq<&'a BStr> for JanetSymbol<'_>
impl<'a, 'b> PartialEq<&'a BStr> for JanetSymbol<'_>
source§impl<'a, 'b> PartialEq<&'a BString> for JanetSymbol<'_>
impl<'a, 'b> PartialEq<&'a BString> for JanetSymbol<'_>
source§impl<'a, 'b> PartialEq<&'a str> for JanetSymbol<'_>
impl<'a, 'b> PartialEq<&'a str> for JanetSymbol<'_>
source§impl<'a, 'b> PartialEq<[u8]> for JanetSymbol<'_>
impl<'a, 'b> PartialEq<[u8]> for JanetSymbol<'_>
source§impl<'a, 'b> PartialEq<BStr> for JanetSymbol<'_>
impl<'a, 'b> PartialEq<BStr> for JanetSymbol<'_>
source§impl<'a, 'b> PartialEq<BString> for JanetSymbol<'_>
impl<'a, 'b> PartialEq<BString> for JanetSymbol<'_>
source§impl PartialEq<JanetKeyword<'_>> for JanetSymbol<'_>
impl PartialEq<JanetKeyword<'_>> for JanetSymbol<'_>
source§fn eq(&self, other: &JanetKeyword<'_>) -> bool
fn eq(&self, other: &JanetKeyword<'_>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialEq<JanetString<'_>> for JanetSymbol<'_>
impl PartialEq<JanetString<'_>> for JanetSymbol<'_>
source§fn eq(&self, other: &JanetString<'_>) -> bool
fn eq(&self, other: &JanetString<'_>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a, 'b> PartialEq<JanetSymbol<'_>> for &'a [u8]
impl<'a, 'b> PartialEq<JanetSymbol<'_>> for &'a [u8]
source§fn eq(&self, other: &JanetSymbol<'_>) -> bool
fn eq(&self, other: &JanetSymbol<'_>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a, 'b> PartialEq<JanetSymbol<'_>> for &'a BStr
impl<'a, 'b> PartialEq<JanetSymbol<'_>> for &'a BStr
source§fn eq(&self, other: &JanetSymbol<'_>) -> bool
fn eq(&self, other: &JanetSymbol<'_>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a, 'b> PartialEq<JanetSymbol<'_>> for &'a BString
impl<'a, 'b> PartialEq<JanetSymbol<'_>> for &'a BString
source§fn eq(&self, other: &JanetSymbol<'_>) -> bool
fn eq(&self, other: &JanetSymbol<'_>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a, 'b> PartialEq<JanetSymbol<'_>> for &'a str
impl<'a, 'b> PartialEq<JanetSymbol<'_>> for &'a str
source§fn eq(&self, other: &JanetSymbol<'_>) -> bool
fn eq(&self, other: &JanetSymbol<'_>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a, 'b> PartialEq<JanetSymbol<'_>> for [u8]
impl<'a, 'b> PartialEq<JanetSymbol<'_>> for [u8]
source§fn eq(&self, other: &JanetSymbol<'_>) -> bool
fn eq(&self, other: &JanetSymbol<'_>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a, 'b> PartialEq<JanetSymbol<'_>> for BStr
impl<'a, 'b> PartialEq<JanetSymbol<'_>> for BStr
source§fn eq(&self, other: &JanetSymbol<'_>) -> bool
fn eq(&self, other: &JanetSymbol<'_>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a, 'b> PartialEq<JanetSymbol<'_>> for BString
impl<'a, 'b> PartialEq<JanetSymbol<'_>> for BString
source§fn eq(&self, other: &JanetSymbol<'_>) -> bool
fn eq(&self, other: &JanetSymbol<'_>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialEq<JanetSymbol<'_>> for JanetKeyword<'_>
impl PartialEq<JanetSymbol<'_>> for JanetKeyword<'_>
source§fn eq(&self, other: &JanetSymbol<'_>) -> bool
fn eq(&self, other: &JanetSymbol<'_>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialEq<JanetSymbol<'_>> for JanetString<'_>
impl PartialEq<JanetSymbol<'_>> for JanetString<'_>
source§fn eq(&self, other: &JanetSymbol<'_>) -> bool
fn eq(&self, other: &JanetSymbol<'_>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a, 'b> PartialEq<JanetSymbol<'_>> for String
impl<'a, 'b> PartialEq<JanetSymbol<'_>> for String
source§fn eq(&self, other: &JanetSymbol<'_>) -> bool
fn eq(&self, other: &JanetSymbol<'_>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a, 'b> PartialEq<JanetSymbol<'_>> for Vec<u8>
impl<'a, 'b> PartialEq<JanetSymbol<'_>> for Vec<u8>
source§fn eq(&self, other: &JanetSymbol<'_>) -> bool
fn eq(&self, other: &JanetSymbol<'_>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a, 'b> PartialEq<JanetSymbol<'_>> for str
impl<'a, 'b> PartialEq<JanetSymbol<'_>> for str
source§fn eq(&self, other: &JanetSymbol<'_>) -> bool
fn eq(&self, other: &JanetSymbol<'_>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a, 'b> PartialEq<String> for JanetSymbol<'_>
impl<'a, 'b> PartialEq<String> for JanetSymbol<'_>
source§impl<'a, 'b> PartialEq<Vec<u8>> for JanetSymbol<'_>
impl<'a, 'b> PartialEq<Vec<u8>> for JanetSymbol<'_>
source§impl<'a, 'b> PartialEq<str> for JanetSymbol<'_>
impl<'a, 'b> PartialEq<str> for JanetSymbol<'_>
source§impl PartialEq for JanetSymbol<'_>
impl PartialEq for JanetSymbol<'_>
source§impl<'a, 'b> PartialOrd<&'a [u8]> for JanetSymbol<'_>
impl<'a, 'b> PartialOrd<&'a [u8]> for JanetSymbol<'_>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'a, 'b> PartialOrd<&'a BStr> for JanetSymbol<'_>
impl<'a, 'b> PartialOrd<&'a BStr> for JanetSymbol<'_>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'a, 'b> PartialOrd<&'a BString> for JanetSymbol<'_>
impl<'a, 'b> PartialOrd<&'a BString> for JanetSymbol<'_>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'a, 'b> PartialOrd<&'a str> for JanetSymbol<'_>
impl<'a, 'b> PartialOrd<&'a str> for JanetSymbol<'_>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'a, 'b> PartialOrd<[u8]> for JanetSymbol<'_>
impl<'a, 'b> PartialOrd<[u8]> for JanetSymbol<'_>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'a, 'b> PartialOrd<BStr> for JanetSymbol<'_>
impl<'a, 'b> PartialOrd<BStr> for JanetSymbol<'_>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'a, 'b> PartialOrd<BString> for JanetSymbol<'_>
impl<'a, 'b> PartialOrd<BString> for JanetSymbol<'_>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<JanetKeyword<'_>> for JanetSymbol<'_>
impl PartialOrd<JanetKeyword<'_>> for JanetSymbol<'_>
source§fn partial_cmp(&self, other: &JanetKeyword<'_>) -> Option<Ordering>
fn partial_cmp(&self, other: &JanetKeyword<'_>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<JanetString<'_>> for JanetSymbol<'_>
impl PartialOrd<JanetString<'_>> for JanetSymbol<'_>
source§fn partial_cmp(&self, other: &JanetString<'_>) -> Option<Ordering>
fn partial_cmp(&self, other: &JanetString<'_>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'a, 'b> PartialOrd<JanetSymbol<'_>> for &'a [u8]
impl<'a, 'b> PartialOrd<JanetSymbol<'_>> for &'a [u8]
source§fn partial_cmp(&self, other: &JanetSymbol<'_>) -> Option<Ordering>
fn partial_cmp(&self, other: &JanetSymbol<'_>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'a, 'b> PartialOrd<JanetSymbol<'_>> for &'a BStr
impl<'a, 'b> PartialOrd<JanetSymbol<'_>> for &'a BStr
source§fn partial_cmp(&self, other: &JanetSymbol<'_>) -> Option<Ordering>
fn partial_cmp(&self, other: &JanetSymbol<'_>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'a, 'b> PartialOrd<JanetSymbol<'_>> for &'a BString
impl<'a, 'b> PartialOrd<JanetSymbol<'_>> for &'a BString
source§fn partial_cmp(&self, other: &JanetSymbol<'_>) -> Option<Ordering>
fn partial_cmp(&self, other: &JanetSymbol<'_>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'a, 'b> PartialOrd<JanetSymbol<'_>> for &'a str
impl<'a, 'b> PartialOrd<JanetSymbol<'_>> for &'a str
source§fn partial_cmp(&self, other: &JanetSymbol<'_>) -> Option<Ordering>
fn partial_cmp(&self, other: &JanetSymbol<'_>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'a, 'b> PartialOrd<JanetSymbol<'_>> for [u8]
impl<'a, 'b> PartialOrd<JanetSymbol<'_>> for [u8]
source§fn partial_cmp(&self, other: &JanetSymbol<'_>) -> Option<Ordering>
fn partial_cmp(&self, other: &JanetSymbol<'_>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'a, 'b> PartialOrd<JanetSymbol<'_>> for BStr
impl<'a, 'b> PartialOrd<JanetSymbol<'_>> for BStr
source§fn partial_cmp(&self, other: &JanetSymbol<'_>) -> Option<Ordering>
fn partial_cmp(&self, other: &JanetSymbol<'_>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'a, 'b> PartialOrd<JanetSymbol<'_>> for BString
impl<'a, 'b> PartialOrd<JanetSymbol<'_>> for BString
source§fn partial_cmp(&self, other: &JanetSymbol<'_>) -> Option<Ordering>
fn partial_cmp(&self, other: &JanetSymbol<'_>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<JanetSymbol<'_>> for JanetKeyword<'_>
impl PartialOrd<JanetSymbol<'_>> for JanetKeyword<'_>
source§fn partial_cmp(&self, other: &JanetSymbol<'_>) -> Option<Ordering>
fn partial_cmp(&self, other: &JanetSymbol<'_>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<JanetSymbol<'_>> for JanetString<'_>
impl PartialOrd<JanetSymbol<'_>> for JanetString<'_>
source§fn partial_cmp(&self, other: &JanetSymbol<'_>) -> Option<Ordering>
fn partial_cmp(&self, other: &JanetSymbol<'_>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'a, 'b> PartialOrd<JanetSymbol<'_>> for String
impl<'a, 'b> PartialOrd<JanetSymbol<'_>> for String
source§fn partial_cmp(&self, other: &JanetSymbol<'_>) -> Option<Ordering>
fn partial_cmp(&self, other: &JanetSymbol<'_>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'a, 'b> PartialOrd<JanetSymbol<'_>> for Vec<u8>
impl<'a, 'b> PartialOrd<JanetSymbol<'_>> for Vec<u8>
source§fn partial_cmp(&self, other: &JanetSymbol<'_>) -> Option<Ordering>
fn partial_cmp(&self, other: &JanetSymbol<'_>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'a, 'b> PartialOrd<JanetSymbol<'_>> for str
impl<'a, 'b> PartialOrd<JanetSymbol<'_>> for str
source§fn partial_cmp(&self, other: &JanetSymbol<'_>) -> Option<Ordering>
fn partial_cmp(&self, other: &JanetSymbol<'_>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'a, 'b> PartialOrd<String> for JanetSymbol<'_>
impl<'a, 'b> PartialOrd<String> for JanetSymbol<'_>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'a, 'b> PartialOrd<Vec<u8>> for JanetSymbol<'_>
impl<'a, 'b> PartialOrd<Vec<u8>> for JanetSymbol<'_>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'a, 'b> PartialOrd<str> for JanetSymbol<'_>
impl<'a, 'b> PartialOrd<str> for JanetSymbol<'_>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd for JanetSymbol<'_>
impl PartialOrd for JanetSymbol<'_>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more