Xen / examples v0.1.0-demo.2
파일 나누기
선택한 언어나 버전에는 이 주제가 없어 같은 영역의 시작 페이지를 표시합니다.
파일 나누기
저장소나 배포본의 루트에서 실행합니다. xen을 PATH에 추가하거나 ./bin/xen으로 바꾸세요.
xen check examples/modules/app.xenxen run examples/modules/app.xen예상 출력
섹션 제목: “예상 출력”tea: 3전체 소스
섹션 제목: “전체 소스”// SPDX-License-Identifier: MIT OR Apache-2.0module app;import shop.model as model;import shop.view as view;
fn main() { let item = model.Item { name: "tea", price: 3 }; view.show(item);}세 파일을 아래 구조로 함께 저장하세요. shop 모듈은 보조 파일이며 직접 실행하지 않습니다.
examples/modules/├── app.xen└── shop/ ├── model.xen └── view.xenshop/model.xen
섹션 제목: “shop/model.xen”// SPDX-License-Identifier: MIT OR Apache-2.0module shop.model;
struct Item { name: String, price: Int }shop/view.xen
섹션 제목: “shop/view.xen”// SPDX-License-Identifier: MIT OR Apache-2.0module shop.view;import shop.model as model;
fn show(item: model.Item) { println(item.name + ": " + int_to_str(item.price));}