如何解决如何在窗口中加入字符?
如何在windows()
中获得的窗口中加入字符?类型为&[char]
。
// Problem: Generate the k-mer Composition of a String
pub fn generate_kmer_composition(s1: &String,k:usize) {
let chars: Vec<char> = s1.chars().collect();
for window in chars.windows(k) {
println!("{:?}",window); //prints lines like ['C','A','T','C']but want CAATC. What can I do with &[char] ?
//println!{"{:?}",window.join(' ')};
// above line gives the following errors: |
// = note: the method `join` exists but the following trait bounds were not satisfied:
// `<[char] as std::slice::Join<_>>::Output = _`
// println!("{:?}",vec!(window).into_iter().collect::<&char>());
// above line results in ^^^^^^^ value of type `&char` cannot be built from `std::iter::Iterator<Item=&[char]>
} }
使用Python和Javascript多年后,我来到了Rust。我一直在努力解决Rosalind的问题,以弄湿我的脚。通常,这些简单的事情比实际的问题对我来说更难。我尝试阅读文档,但是我不确定如何从&[char]开始获取我想要的一串字符,并按顺序加入。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。