| Crates.io | shogi_core |
| lib.rs | shogi_core |
| version | 0.1.5 |
| created_at | 2022-05-15 03:51:53.6533+00 |
| updated_at | 2022-08-05 10:06:45.41982+00 |
| description | Fundamental types and functions for shogi |
| homepage | |
| repository | https://github.com/rust-shogi-crates/shogi_core/tree/main/shogi_core |
| max_upload_size | |
| id | 586895 |
| size | 170,147 |
rlib)This crate defines fundamental types and functions for shogi (Japanese chess). The documentation of this crate may be used for the reference of detailed rules of shogi, although it is not intended for introduction to rules.
This crate supports users that follow shogi rules or something stricter than them, such as shogi engines, capture-only variant shogi engines, mate solvers, helpmate solvers, stalemate solvers. This crate does not support fairy mate problems in general. One might be able to make use of this crate for such shogi variants, but it is not guaranteed.
This crate provides fundamental data types and functions used in shogi.
This crate does not provide legality checking. There are many ways to check legality, so it is responsibility of other crates.
This crate supports output of SFEN + moves format. This helps easy testing of positions. This crate does not support reading of SFEN + moves format because of its complexity. Other crates are responsible for this.
This crate depends only on core::* and alloc::*. This crate does not depend on std::*.
There are environments where depending on alloc is impossible. In order to support such environments, items in this crate depend only on core as much as possible, and items that must depend on alloc are separated by alloc feature.
This crate does not depend on any other crates.
Functions in this crate that do not depend on alloc do not panic.
Functions that depend on alloc can panic because they require memory allocation, which can fail due to out of memory. Otherwise, they do not panic.
This crate may provide unsafe items under the following conditions:
_unchecked in their name so that unsafety of them is obvious.Safety section in the document, the conditions imposed on arguments for an unsafe item not to cause undefined behavior are described.This crate defines types representing the following entities. An entity below can depend on entities above.
Types are defined so that discriminant elision applies for as many types as possible. Some types even have guarantees about discriminant elision.
Eq, PartialEq, Ord and PartialOrdEq and PartialEq are implemented for all types because we need equality testing in tests anyway, and because if we need equality testing in tests, there are assumed to be other use cases.
Ord and PartialOrd are implemented when ord feature is enabled (which is disabled by default), so that types in this crate can be used as keys of e.g. BTreeMap.
Clone and CopyClone is implemented for every type. Copy is implemented if we can assume that a type will be Copy forever. For example, player to move, square, piece and hand implement Copy, but position doesn't.
HashThere are assumed to be two main use cases when one wants to take a hash value of data of shogi:
HashMap in order to casually create maps whose keys are positions.For 1., it is not the place of implementations in the library because one needs to make their own hash function. For 2., some but not all users may need these implementations. They are made available if the hash feature is enabled.
DefaultBitboard and position implement Default. The other types don't implement Default because there are no values suitable for default.
DebugAlways implemented.
DisplayNot implemented because there are multiple string representations and no canonical string representation among them. (For example, a pawn can be represented as 歩, FU, P or Pawn.)
This crate defines the trait ToUsi which defines to_usi method, which handles conversion to string representations in USI format.
From, TryFromImplemented when necessary.
AsRef, AsMutNot implemented.
alloc: alloc-related functionalities are made available. Enabled by default.std: std-related functionalities are made available. Implies alloc. Enabled by default.hash: implements Hash for every type it exports.ord: implements PartialOrd and Ord for every type it exports.experimental: enables experimental functionalities. Items marked as experimental are considered exempt from semantic versioning, and subject to change or deletion without notice.