• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rust-bio / rust-htslib / 15210311750

23 May 2025 12:29PM UTC coverage: 83.513% (-0.09%) from 83.605%
15210311750

Pull #476

github

web-flow
Merge b8fdd3d3c into 8741513e4
Pull Request #476: feat: Allow for non-diploid genotypes

15 of 25 new or added lines in 3 files covered. (60.0%)

61 existing lines in 11 files now uncovered.

2710 of 3245 relevant lines covered (83.51%)

25632.95 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

76.19
/src/utils.rs
1
// Copyright 2014 Christopher Schröder, Johannes Köster.
2
// Licensed under the MIT license (http://opensource.org/licenses/MIT)
3
// This file may not be copied, modified, or distributed
4
// except according to those terms.
5

6
//! Module with utility code.
7

8
use crate::errors::{Error, Result};
9
use std::ffi;
10
use std::path::Path;
11
use std::ptr;
12

13
/// Copies data from `src` to `dst`
14
/// TODO remove once stable in standard library.
15
///
16
/// Panics if the length of `dst` is less than the length of `src`.
17
#[inline]
18
pub fn copy_memory(src: &[u8], dst: &mut [u8]) {
91,134✔
19
    let len_src = src.len();
273,384✔
20
    assert!(
91,129✔
21
        dst.len() >= len_src,
182,250✔
22
        "dst len {} < src len {}",
×
23
        dst.len(),
×
24
        src.len()
×
25
    );
26
    // `dst` is unaliasable, so we know statically it doesn't overlap
27
    // with `src`.
28
    unsafe {
29
        ptr::copy_nonoverlapping(src.as_ptr(), dst.as_mut_ptr(), len_src);
455,634✔
30
    }
31
}
32

33
pub fn path_to_cstring<P: AsRef<Path>>(path: &P) -> Option<ffi::CString> {
18✔
34
    path.as_ref()
18✔
35
        .to_str()
36
        .and_then(|p| ffi::CString::new(p).ok())
66✔
37
}
38

39
/// Convert a path into a byte-vector
40
pub fn path_as_bytes<'a, P: 'a + AsRef<Path>>(path: P, must_exist: bool) -> Result<Vec<u8>> {
500,121✔
41
    if path.as_ref().exists() || !must_exist {
1,000,268✔
42
        Ok(path
500,154✔
43
            .as_ref()
500,103✔
UNCOV
44
            .to_str()
×
UNCOV
45
            .ok_or(Error::NonUnicodePath)?
17✔
46
            .as_bytes()
500,103✔
UNCOV
47
            .to_owned())
×
48
    } else {
49
        Err(Error::FileNotFound {
2✔
50
            path: path.as_ref().to_owned(),
2✔
51
        })
52
    }
53
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc