Skip to content

Commit

Permalink
Add example to TranslationTable::to_fn
Browse files Browse the repository at this point in the history
  • Loading branch information
swooster committed Dec 1, 2022
1 parent 6e79826 commit df75fce
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/trans_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,19 @@ impl TranslationTable {
///
/// Currently, amino acids are represented as [`u8`]s containing the ascii
/// code for the corresponding letter abbreviation.
///
/// # Examples
///
/// ```
/// use quickdna::{Nucleotide, NucleotideIter, TranslationTable};
///
/// use Nucleotide::*;
/// let dna = [A, T, C, G, A, T, C, G];
///
/// let ncbi1 = TranslationTable::Ncbi1.to_fn();
/// let aas = dna.iter().codons().map(ncbi1);
/// assert!(aas.eq([b'I', b'D']));
/// ```
pub fn to_fn<C: Into<CodonIdx>>(self) -> impl Copy + Fn(C) -> u8 {
let start = self.table_index() * Self::CODONS_PER_TABLE;
let end = start + Self::CODONS_PER_TABLE;
Expand Down

0 comments on commit df75fce

Please sign in to comment.