<commit_before>//! # Find the last box of a list.
//! # example
///```
///use p99::p1::my_last;
///assert_eq!(my_last(&['a','b','c','d']),Some(['d']));
///assert_eq!(my_last(&['d']),Some(['d']));
///assert_eq!(my_last(&[]),None);
///```

pub fn my_last(list: &[char]) -> Option<[char; 1]> {
    if list.len() > 0 {
        Some([list[list.len() - 1]])
    } else {
        None
    }
}<commit_msg>generic function p1<commit_after>//! # Find the last box of a list.
//! # example
///```
///use p99::p1::my_last;
///assert_eq!(my_last(&['a','b','c','d']),Some(['d']));
///assert_eq!(my_last(&['d']),Some(['d']));
///let list: &[char] = &[];
///assert_eq!(my_last(list),None);
///```
// TODO should rewrite about line to assert_eq!(&[]:&[char])
// after issue 23416 implemented

use std::clone::Clone;
pub fn my_last<T>(list: &[T]) -> Option<[T; 1]> where T: PartialEq + Clone {
    if list.len() > 0 {
        Some([list[list.len() - 1].clone()])
    } else {
        None
    }
}
{'fraction_non_alphanumeric': 0.2995910020449898, 'fraction_numerical': 0.018404907975460124, 'mean_word_length': 3.293859649122807, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1001399', 'n_tokens_mistral': 402, 'n_tokens_neox': 380, 'n_words': 76}