# base/version (vanilla-engine 0.4.0)

> https://vanillapunch.com/docs/vanilla-engine/0.4.0/api/base/version/

판. (major.minor.patch, 브랜치가 있으면 major.minor.patch-branch, 원본 base/version.js)
- 필드를 그대로 열고, 원본의 get_major / set_major 같은 접근자와 getVersionString 도 같은 이름으로 둔다.
- 브랜치가 글이라 Copy 가 아니다. create 는 원본 기본 인자처럼 브랜치 없이, create_with_branch 는 브랜치를 받는다.

## Version (struct) (Clone, Debug, PartialEq, Eq)

판. (주, 부, 패치 번호와 브랜치 이름)

예제: 판 글 만들고 브랜치 붙이기

```rust
use vanilla::Version;

let mut version = Version::create(0, 4, 0);
assert_eq!(version.to_string(), "0.4.0");
version.set_branch("experimental");
assert_eq!(version.get_version_string(), "0.4.0-experimental");
version.patch += 1;
assert_eq!(version, Version::create_with_branch(0, 4, 1, "experimental"));
```

- `pub major: u32` (field, since 0.3.2): 주 판 번호.
  - returns u32
- `pub minor: u32` (field, since 0.3.2): 부 판 번호.
  - returns u32
- `pub patch: u32` (field, since 0.3.2): 패치 판 번호.
  - returns u32
- `pub branch: String` (field, since 0.4.0): 브랜치 이름. (빈 글이면 브랜치 없음)
  - returns String
- `pub const fn create(major: u32, minor: u32, patch: u32) -> Version` (static, since 0.3.2): 생성. (브랜치 없음)
  - `major` u32: 주 판 번호.
  - `minor` u32: 부 판 번호.
  - `patch` u32: 패치 판 번호.
  - returns Version: 브랜치 없는 판. (const fn 이라 상수로 둘 수 있다)

  예제: 게임 판을 상수로

  ```rust
  use vanilla::Version;
  
  const GAME_VERSION: Version = Version::create(1, 2, 3);
  assert_eq!(GAME_VERSION.to_string(), "1.2.3");
  ```

- `pub fn create_with_branch(major: u32, minor: u32, patch: u32, branch: &str) -> Version` (static, since 0.4.0): 브랜치를 붙여 생성. (빈 글이면 브랜치 없음)
  - `major` u32: 주 판 번호.
  - `minor` u32: 부 판 번호.
  - `patch` u32: 패치 판 번호.
  - `branch` &str: 브랜치 이름. (빈 글이면 브랜치 없음)
  - returns Version: 그 브랜치를 붙인 판.
- `pub fn set_major(&mut self, major: u32)` (method, since 0.4.0): 주 판 설정과 반환.
  - `major` u32: 새 주 판 번호.
- `pub fn get_major(&self) -> u32` (method, since 0.4.0): 주 판 반환.
  - returns u32: 주 판 번호.
- `pub fn set_minor(&mut self, minor: u32)` (method, since 0.4.0): 부 판 설정과 반환.
  - `minor` u32: 새 부 판 번호.
- `pub fn get_minor(&self) -> u32` (method, since 0.4.0): 부 판 반환.
  - returns u32: 부 판 번호.
- `pub fn set_patch(&mut self, patch: u32)` (method, since 0.4.0): 패치 판 설정과 반환.
  - `patch` u32: 새 패치 판 번호.
- `pub fn get_patch(&self) -> u32` (method, since 0.4.0): 패치 판 반환.
  - returns u32: 패치 판 번호.
- `pub fn set_branch(&mut self, branch: &str)` (method, since 0.4.0): 브랜치 설정과 반환. (빈 글이면 브랜치 없음)
  - `branch` &str: 새 브랜치 이름. (빈 글이면 브랜치 없음)
- `pub fn get_branch(&self) -> &str` (method, since 0.4.0): 브랜치 반환.
  - returns &str: 브랜치 이름. (없으면 빈 글)
- `pub fn get_version_string(&self) -> String` (method, since 0.4.0): 판 문자열. (원본 getVersionString, to_string 과 같다)
  - returns String: to_string 과 같은 판 글.
- `pub fn to_string(&self) -> String` (method, since 0.3.2): "major.minor.patch" 문자열. (브랜치가 있으면 "major.minor.patch-branch")
  - returns String: 판 글. ("0.3.2", 브랜치가 있으면 "0.4.0-experimental" 처럼 하이픈 뒤에 붙인다)
