bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 73쪽 중 8쪽
lower bound of the range (inclusive).
#### Signature
```rust theme={null}
pub start: T
```
### end
The upper bound of the range (inclusive).
#### Signature
```rust theme={null}
pub end: T
```
# core::ops::range::RangeInclusiveIterator
Source: https://docs.starknet.io/build/corelib/core-ops-range-RangeInclusiveIterator
## Signature
```rust theme={null}
#[derive(Clone, Drop)]
pub struct RangeInclusiveIterator {
pub(crate) cur: T,
pub(crate) end: T,
pub(crate) exhausted: bool,
}
```
# core::ops::range::RangeInclusiveTrait
Source: https://docs.starknet.io/build/corelib/core-ops-range-RangeInclusiveTrait
## Signature
```rust theme={null}
pub trait RangeInclusiveTrait+PartialOrd>
```
## Trait functions
### contains
Returns `true` if `item` is contained in the range.
#### Signature
```rust theme={null}
fn contains, +PartialOrd, T, +Destruct, +PartialOrd>(
self: @RangeInclusive, item: @T,
) -> bool
```
#### Examples
```rust theme={null}
assert!(!(3..=5).contains(@2));
assert!( (3..=5).contains(@3));
assert!( (3..=5).contains(@4));
assert!( (3..=5).contains(@5));
assert!(!(3..=5).contains(@6));
assert!( (3..=3).contains(@3));
assert!(!(3..=2).contains(@3));
```
### is\_empty
Returns `true` if the range contains no items.
#### Signature
```rust theme={null}
fn is_empty, +PartialOrd, T, +Destruct, +PartialOrd>(
self: @RangeInclusive,
) -> bool
```
#### Examples
```rust theme={null}
assert!(!(3_u8..=5_u8).is_empty());
assert!(!(3_u8..=3_u8).is_empty());
assert!( (3_u8..=2_u8).is_empty());
```
# core::ops::range::RangeIterator
Source: https://docs.starknet.io/build/corelib/core-ops-range-RangeIterator
Represents an iterator located at `cur`, whose end is `end` (`cur < end`).
```rust theme={null}
struct RangeIterator<T> {
cur: T,
end: T,
}
```
# core::ops::range::RangeTrait
Source: https://docs.starknet.io/build/corelib/core-ops-range-RangeTrait
## Signature
```rust theme={null}
pub trait RangeTrait+PartialOrd>
```
## Trait functions
### contains
Returns `true` if `item` is contained in the range.
#### Signature
```rust theme={null}
fn contains, +PartialOrd, T, +Destruct, +PartialOrd>(
self: @Range, item: @T,
) -> bool
```
#### Examples
```rust theme={null}
assert!(!(3..5).contains(@2));
assert!( (3..5).contains(@3));
assert!( (3..5).contains(@4));
assert!(!(3..5).contains(@5));
assert!(!(3..3).contains(@3));
assert!(!(3..2).contains(@3));
```
### is\_empty
Returns `true` if the range contains no items.
#### Signature
```rust theme={null}
fn is_empty, +PartialOrd, T, +Destruct, +PartialOrd>(
self: @Range,
) -> bool
```
#### Examples
```rust theme={null}
assert!(!(3_u8..5_u8).is_empty());
assert!( (3_u8..3_u8).is_empty());
assert!( (3_u8..2_u8).is_empty());
```
# core::option::Option
Source: https://docs.starknet.io/build/corelib/core-option-Option
The `Option` enum representing either `Some(value)` or `None`.
## Signature
```rust theme={null}
pub enum Option {
Some: T,
None,
}
```
## Variants
### Some
#### Signature
```rust theme={null}
Some: T
```
### None
#### Signature
```rust theme={null}
None
```
# core::option::OptionTrait
Source: https://docs.starknet.io/build/corelib/core-option-OptionTrait
A trait for handling `Option` related operations.
## Signature
```rust theme={null}
pub trait OptionTrait
```
## Trait functions
### expect
Returns the contained `Some` value, consuming the `self` value.
#### Signature
```rust theme={null}
fn expect(self: Option, err: felt252) -> T
```
#### Panics
Panics if the option value is `None` with a custom `felt252` panic message `err`.
#### Examples
```rust theme={null}
let option = Some(123);
let value = option.expect('no value');
assert!(value == 123);
```
### unwrap
Returns the contained `Some` value, consuming the `self` value.
#### Signature
```rust theme={null}
fn unwrap(self: Option) -> T
```
#### Panics
Panics if the `self` value equals `None`.
#### Examples
```rust theme={null}
let option = Some(123);
let value = option.unwrap();
assert!(value == 123);
```
### ok\_or
Transforms the `Option` into a `Result`, mapping `Some(v)` to
`Ok(v)` and `None` to `Err(err)`.
#### Signature
```rust theme={null}
fn ok_or>(self: Option, err: E) -> Result
```
#### Examples
```rust theme={null}
assert_eq!(Some('foo').ok_or(0), Ok('foo'));
let option: Option = None;
assert_eq!(option.ok_or(0), Err(0));
```
### ok\_or\_else
Transforms the `Option` into a `Result`, mapping `Some(v)` to
`Ok(v)` and `None` to `Err(err())`.
#### Signature
```rust theme={null}
fn ok_or_else, +core::ops::FnOnce[Output: E], +Drop>(
self: Option, err: F,
) -> Result
```
#### Examples
```rust theme={null}
assert_eq!(Some('foo').ok_or_else(|| 0), Ok('foo'));
let option: Option = None;
assert_eq!(option.ok_or_else(|| 0), Err(0));
```
### and
Returns [`None`](./core-option#none) if the option is [`None`](./core-option#none), otherwise returns `optb`.
Arguments passed to `and` are eagerly evaluated; if you are passing the
result of a function call, it is recommended to use `and_then`, which is
lazily evaluated.
#### Signature
```rust theme={null}
fn and, +Drop>(self: Option, optb: Option) -> Option
```
#### Examples
```rust theme={null}
let x = Some(2);
let y: Option = None;
assert_eq!(x.and(y), None);
let x: Option = None;
let y: Option = Some("foo");
assert_eq!(x.and(y), None);
let x = Some(2);
let y: Option = Some("foo");
assert_eq!(x.and(y), Some("foo"));
let x: Option = None;
let y: Option = None;
assert_eq!(x.and(y), None);
```
### and\_then
Returns [`None`](./core-option#none) if the option is [`None`](./core-option#none), otherwise calls `f` with the
wrapped value and returns the result.
Some languages call this operation flatmap.
#### Signature
```rust theme={null}
fn and_then, +core::ops::FnOnce[Output: Option]>(
self: Option, f: F,
) -> Option
```
#### Examples
```rust theme={null}
use core::num::traits::CheckedMul;
let option: Option = checked_mul(2_u32, 2_u32)
.and_then(|v| Some(format!("{}", v)));
assert_eq!(option, Some("4"));
let option: Option = checked_mul(65536_u32, 65536_u32)
.and_then(|v| Some(format!("{}", v)));
assert_eq!(option, None); // overflowed!
let option: Option = Option::::None
.and_then(|v| Some(format!("{}", v)));
assert_eq!(option, None);
```
### or
Returns the option if it contains a value, otherwise returns `optb`.
Arguments passed to `or` are eagerly evaluated; if you are passing the
result of a function call, it is recommended to use `or_else`, which is
lazily evaluated.
#### Signature
```rust theme={null}
fn or>(self: Option, optb: Option) -> Option
```
#### Examples
```rust theme={null}
let x = Some(2);
let y = None;
assert_eq!(x.or(y), Some(2));
let x = None;
let y = Some(100);
assert_eq!(x.or(y), Some(100));
let x = Some(2);
let y = Some(100);
assert_eq!(x.or(y), Some(2));
let x: Option = None;
let y = None;
assert_eq!(x.or(y), None);
```
### or\_else
Returns the option if it contains a value, otherwise calls `f` and
returns the result.
#### Signature
```rust theme={null}
fn or_else, +core::ops::FnOnce[Output: Option]>(
self: Option, f: F,
) -> Option
```
#### Examples
```rust theme={null}
let nobody = || Option::::None;
let vikings = || Option::::Some("vikings");
assert_eq!(Some("barbarians").or_else(vikings), Some("barbarians"));
assert_eq!(None.or_else(vikings), Some("vikings"));
assert_eq!(None.or_else(nobody), None);
```
### xor
Returns [`Some`](./core-option#some) if exactly one of `self`, `optb` is [`Some`](./core-option#some), otherwise returns [`None`](./core-option#none).
#### Signature
```rust theme={null}
fn xor>(self: Option, optb: Option) -> Option
```
#### Examples
```rust theme={null}
let x = Some(2);
let y: Option = None;
assert_eq!(x.xor(y), Some(2));
let x: Option = None;
let y = Some(2);
assert_eq!(x.xor(y), Some(2));
let x = Some(2);
let y = Some(2);
assert_eq!(x.xor(y), None);
let x: Option = None;
let y: Option = None;
assert_eq!(x.xor(y), None);
```
### is\_some
Returns `true` if the `Option` is `Some`, `false` otherwise.
#### Signature
```rust theme={null}
fn is_some(self: @Option) -> bool
```
#### Examples
```rust theme={null}
let option = Some(123);
assert!(option.is_some());
```
### is\_some\_and
Returns `true` if the `Option` is `Some` and the value inside of it matches a
predicate.
#### Signature
```rust theme={null}
fn is_some_and, +core::ops::FnOnce[Output: bool]>(
self: Option, f: F,
) -> bool
```
#### Examples
```rust theme={null}
assert_eq!(Some(2_u8).is_some_and(|x| x > 1), true);
assert_eq!(Some(0_u8).is_some_and(|x| x > 1), false);
let option: Option = None;
assert_eq!(option.is_some_and(|x| x > 1), false);
```
### is\_none
Returns `true` if the `Option` is `None`, `false` otherwise.
#### Signature
```rust theme={null}
fn is_none(self: @Option) -> bool
```
#### Examples
```rust theme={null}
let option = Some(123);
assert!(!option.is_none());
```
### is\_none\_or
Returns `true` if the `Option` is `None` or the value inside of it matches a
predicate.
#### Signature
```rust theme={null}
fn is_none_or, +core::ops::FnOnce[Output: bool]>(
self: Option, f: F,
) -> bool
```
#### Examples
```rust theme={null}
assert_eq!(Some(2_u8).is_none_or(|x| x > 1), true);
assert_eq!(Some(0_u8).is_none_or(|x| x > 1), false);
let option: Option = None;
assert_eq!(option.is_none_or(|x| x > 1), true);
```
### unwrap\_or
Returns the contained `Some` value if `self` is `Some(x)`. Otherwise, returns the
provided default.
#### Signature
```rust theme={null}
fn unwrap_or>(self: Option, default: T) -> T
```
#### Examples
```rust theme={null}
let option = Some(123);
assert!(option.unwrap_or(456) == 123);
let option = None;
assert!(option.unwrap_or(456) == 456);
```
### unwrap\_or\_default
Returns the contained `Some` value if `self` is `Some(x)`. Otherwise, returns
`Default::::default()`.
#### Signature
```rust theme={null}
fn unwrap_or_default>(self: Option) -> T
```
#### Examples
```rust theme={null}
let option = Some(123);
assert!(option.unwrap_or_default() == 123);
let option: Option = None;
assert!(option.unwrap_or_default() == Default::default());
```
### unwrap\_or\_else
Returns the contained [`Some`](./core-option#some) value or computes it from a closure.
#### Signature
```rust theme={null}
fn unwrap_or_else, impl func: FnOnce, +Drop>(
self: Option, f: F,
) -> T
```
#### Examples
```rust theme={null}
let k = 10;
assert!(Some(4).unwrap_or_else(|| 2 * k) == 4);
assert!(None.unwrap_or_else(|| 2 * k) == 20);
```
### map
Maps an `Option` to `Option` by applying a function to a contained value (if `Some`)
or returns `None` (if `None`).
#### Signature
```rust theme={null}
fn map, +core::ops::FnOnce[Output: U]>(
self: Option, f: F,
) -> Option
```
#### Examples
```rust theme={null}
let maybe_some_string: Option = Some("Hello, World!");
// `Option::map` takes self *by value*, consuming `maybe_some_string`
let maybe_some_len = maybe_some_string.map(|s: ByteArray| s.len());
assert!(maybe_some_len == Some(13));
let x: Option = None;
assert!(x.map(|s: ByteArray| s.len()) == None);
```
### map\_or
Returns the provided default result (if none),
or applies a function to the contained value (if any).
Arguments passed to `map_or` are eagerly evaluated; if you are passing
the result of a function call, it is recommended to use `map_or_else`,
which is lazily evaluated.
#### Signature
```rust theme={null}
fn map_or, +Drop, +core::ops::FnOnce[Output: U]>(
self: Option, default: U, f: F,
) -> U
```
#### Examples
```rust theme={null}
assert_eq!(Some("foo").map_or(42, |v: ByteArray| v.len()), 3);
let x: Option = None;
assert_eq!(x.map_or(42, |v: ByteArray| v.len()), 42);
```
### map\_or\_else
Computes a default function result (if none), or
applies a different function to the contained value (if any).
#### Signature
```rust theme={null}
fn map_or_else,
+Drop,
+Drop,
+core::ops::FnOnce[Output: U],
+core::ops::FnOnce[Output: U],
>(
self: Option, default: D, f: F,
) -> U
```
#### Examples
```rust theme={null}
let k = 21;
let x = Some("foo");
assert_eq!(x.map_or_else( || 2 * k, |v: ByteArray| v.len()), 3);
let x: Option = None;
assert_eq!(x.map_or_else( || 2 * k, |v: ByteArray| v.len()), 42);
```
### take
Takes the value out of the option, leaving a [`None`](./core-option#none) in its place.
#### Signature
```rust theme={null}
fn take(ref self: Option) -> Option
```
#### Examples
```rust theme={null}
let mut x = Some(2);
let y = x.take();
assert_eq!(x, None);
assert_eq!(y, Some(2));
let mut x: Option = None;
let y = x.take();
assert_eq!(x, None);
assert_eq!(y, None);
```
### filter
Returns [`None`](./core-option#none) if the option is [`None`](./core-option#none), otherwise calls `predicate`
with the wrapped value and returns:
* `Some(t)` if `predicate` returns `true` (where `t` is the wrapped
value), and
* [`None`](./core-option#none) if `predicate` returns `false`.
#### Signature
```rust theme={null}
fn filter[Output: bool], +Destruct, +Destruct>(
self: Option, predicate: P,
) -> Option
```
#### Examples
```rust theme={null}
let is_even = |n: @u32| -> bool {
*n % 2 == 0
};
assert_eq!(None.filter(is_even), None);
assert_eq!(Some(3).filter(is_even), None);
assert_eq!(Some(4).filter(is_even), Some(4));
```
### flatten
Converts from `Option>` to `Option`.
#### Signature
```rust theme={null}
fn flatten(self: Option>) -> Option
```
#### Examples
Basic usage:
```rust theme={null}
let x: Option> = Some(Some(6));
assert_eq!(Some(6), x.flatten());
let x: Option> = Some(None);
assert_eq!(None, x.flatten());
let x: Option> = None;
assert_eq!(None, x.flatten());
```
Flattening only removes one level of nesting at a time:
```rust theme={null}
let x: Option>> = Some(Some(Some(6)));
assert_eq!(Some(Some(6)), x.flatten());
assert_eq!(Some(6), x.flatten().flatten());
```
# core::panic_with_const_felt252
Source: https://docs.starknet.io/build/corelib/core-panic_with_const_felt252
Panics with the given const argument `felt252` as error message.
## Signature
```rust theme={null}
pub fn panic_with_const_felt252() -> never
```
## Examples
```rust theme={null}
use core::panic_with_const_felt252;
panic_with_const_felt252::();
```
# core::panic_with_felt252
Source: https://docs.starknet.io/build/corelib/core-panic_with_felt252
Panics with the given `felt252` as error message.
## Signature
```rust theme={null}
pub fn panic_with_felt252(err_code: felt252) -> never
```
## Examples
```rust theme={null}
use core::panic_with_felt252;
panic_with_felt252('error message');
```
# panic
Source: https://docs.starknet.io/build/corelib/core-panics-Panic
## panic
```rust theme={null}
extern fn panic(data: Array<felt252>) -> never;
```
Triggers an immediate panic with the provided data and terminates execution.
This function is the core panic mechanism in Cairo. When called, it:
1. Takes an array of `felt252` values as panic data
2. Terminates the current execution
3. Propagates the panic data up the call stack
### Parameters
* `data: Array<felt252>` - The panic data to be included with the panic
### Returns
* `never` - This function never returns as it terminates execution
### Example
```rust theme={null}
use core::panics::panic;
// Panic with custom data
panic(array!['Error code', 42, 'Additional info']);
```
### Related Functions
* [`panic_with_byte_array`](./core-panics-panic_with_byte_array) - Panic with a `ByteArray` message
* [`panic!` macro](./core-panic_with_felt252) - Convenient macro for panicking with messages
# core::panics::PanicResult
Source: https://docs.starknet.io/build/corelib/core-panics-PanicResult
Result type for operations that can trigger a panic.
## Signature
```rust theme={null}
pub enum PanicResult {
Ok: T,
Err: (Panic, Array),
}
```
## Variants
### Ok
#### Signature
```rust theme={null}
Ok: T
```
### Err
#### Signature
```rust theme={null}
Err: (Panic, Array)
```
# core::panics::panic_with_byte_array
Source: https://docs.starknet.io/build/corelib/core-panics-panic_with_byte_array
Panics with a `ByteArray` message.
Constructs a panic message by prepending the `BYTE_ARRAY_MAGIC` value and
serializing the provided `ByteArray` into the panic data.
## Signature
```rust theme={null}
pub fn panic_with_byte_array(err: ByteArray) -> never
```
## Examples
```rust theme={null}
use core::panics::panic_with_byte_array;
let error_msg = "An error occurred";
panic_with_byte_array(@error_msg);
```
# core::pedersen::HashState
Source: https://docs.starknet.io/build/corelib/core-pedersen-HashState
Represents the current state of a Pedersen hash computation.
The state is maintained as a single `felt252` value, which is updated
through the `HashStateTrait::finalize` method.
## Signature
```rust theme={null}
#[derive(Copy, Drop, Debug)]
pub struct HashState {
pub state: felt252,
}
```
## Members
### state
The current hash state
#### Signature
```rust theme={null}
pub state: felt252
```
# pedersen
Source: https://docs.starknet.io/build/corelib/core-pedersen-Pedersen
## pedersen
```rust theme={null}
extern fn pedersen(a: felt252, b: felt252) -> felt252;
```
Computes the Pedersen hash of two `felt252` values.
The Pedersen hash function is a collision-resistant cryptographic hash function that takes two field elements as input and produces a single field element as output.
### Parameters
* `a: felt252` - The first input value
* `b: felt252` - The second input value
### Returns
* `felt252` - The Pedersen hash of the two input values
### Example
```rust theme={null}
use core::pedersen::pedersen;
let hash = pedersen(1, 2);
// Result: hash value as felt252
```
### Related
* [`HashState`](./core-pedersen-HashState) - For computing Pedersen hashes of multiple values
* [`PedersenTrait`](./core-pedersen-PedersenTrait) - Trait for creating new hash states
# core::pedersen::PedersenImpl
Source: https://docs.starknet.io/build/corelib/core-pedersen-PedersenImpl
A trait for creating a new Pedersen hash state.
## Signature
```rust theme={null}
pub impl PedersenImpl of PedersenTrait;
```
## Impl functions
### new
Creates a new Pedersen hash state with the given base value.
#### Signature
```rust theme={null}
fn new(base: felt252) -> HashState
```
#### Examples
```rust theme={null}
use core::pedersen::PedersenTrait;
let mut state = PedersenTrait::new(0);
assert!(state.state == 0);
```
# core::pedersen::PedersenTrait
Source: https://docs.starknet.io/build/corelib/core-pedersen-PedersenTrait
## Signature
```rust theme={null}
pub trait PedersenTrait
```
## Trait functions
### new
Creates a new Pedersen hash state with the given base value.
#### Signature
```rust theme={null}
fn new(base: felt252) -> HashState
```
#### Examples
```rust theme={null}
use core::pedersen::PedersenTrait;
let mut state = PedersenTrait::new(0);
assert!(state.state == 0);
```
# core::poseidon::HashState
Source: https://docs.starknet.io/build/corelib/core-poseidon-HashState
State for Poseidon hash.
## Signature
```rust theme={null}
#[derive(Copy, Drop, Debug)]
pub struct HashState {
pub s0: felt252,
pub s1: felt252,
pub s2: felt252,
pub odd: bool,
}
```
## Members
### s0
#### Signature
```rust theme={null}
pub s0: felt252
```
### s1
#### Signature
```rust theme={null}
pub s1: felt252
```
### s2
#### Signature
```rust theme={null}
pub s2: felt252
```
### odd
#### Signature
```rust theme={null}
pub odd: bool
```
# core::poseidon::Poseidon
Source: https://docs.starknet.io/build/corelib/core-poseidon-Poseidon
## Signature
```rust theme={null}
pub extern type Poseidon;
```
# core::poseidon::PoseidonImpl
Source: https://docs.starknet.io/build/corelib/core-poseidon-PoseidonImpl
A trait for creating a new Poseidon hash state.
## Signature
```rust theme={null}
pub impl PoseidonImpl of PoseidonTrait;
```
## Impl functions
### new
Creates an initial state with all fields set to 0.
#### Signature
```rust theme={nu프로젝트로 돌아가기