Skip to content

Commit 1c351a6

Browse files
committed
Add Env::make_vector and Env::vector functions
1 parent a729fea commit 1c351a6

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
55

66
## [Unreleased]
7+
- Added `Env::make_vector` and `Env::vector` functions.
78
- Added a default implementation for `Transfer::type_name`. This raised the minimum supported Rust version to 1.38 (for `std::any::type_name()`).
89
- Added function to copy a Lisp string's content to a buffer `Value::copy_string_contents`.
910
- Deprecated `unwrap_or_propagate`, and marked it as `unsafe`.

src/types/vector.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::convert::TryInto;
22

33
use super::*;
4+
use crate::call::IntoLispArgs;
45

56
/// A type that represents Lisp vectors. This is a newtype wrapper around [`Value`] that provides
67
/// vector-specific methods.
@@ -68,3 +69,13 @@ impl<'e> IntoLisp<'e> for Vector<'e> {
6869
Ok(self.0)
6970
}
7071
}
72+
73+
impl Env {
74+
pub fn make_vector<'e, T: IntoLisp<'e>>(&'e self, length: usize, init: T) -> Result<Vector> {
75+
self.call("make-vector", (length, init)).map(Vector)
76+
}
77+
78+
pub fn vector<'e, A: IntoLispArgs<'e>>(&'e self, args: A) -> Result<Vector> {
79+
self.call("vector", args).map(Vector)
80+
}
81+
}

0 commit comments

Comments
 (0)