Skip to content

Commit

Permalink
feat: Replace Arc with Rc to fix clippy lint
Browse files Browse the repository at this point in the history
Fix the clippy lint:
Error: error: usage of an `Arc` that is not `Send` and `Sync`
  • Loading branch information
sjackman committed Jul 15, 2024
1 parent 229c22a commit 6cae26f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
12 changes: 5 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::io::BufReader;
use std::os::raw::c_char;
use std::os::raw::c_int;
use std::path::Path;
use std::sync::Arc;
use std::rc::Rc;

use anyhow::{format_err, Error};
use rust_htslib::bam;
Expand All @@ -16,7 +16,7 @@ use rust_htslib::bam::HeaderView;
use star_sys::{self as bindings, Aligner as BindAligner, StarRef as BindRef};

pub struct StarReference {
inner: Arc<InnerStarReference>,
inner: Rc<InnerStarReference>,
}

struct InnerStarReference {
Expand All @@ -26,8 +26,6 @@ struct InnerStarReference {
header_view: HeaderView,
}

unsafe impl Sync for InnerStarReference {}

impl Drop for InnerStarReference {
fn drop(&mut self) {
unsafe {
Expand Down Expand Up @@ -65,7 +63,7 @@ impl StarReference {
};

Ok(StarReference {
inner: Arc::new(inner),
inner: Rc::new(inner),
})
}

Expand Down Expand Up @@ -151,7 +149,7 @@ impl StarSettings {
/// rust_htslib Record objects
pub struct StarAligner {
aligner: *mut BindAligner,
reference: Arc<InnerStarReference>,
reference: Rc<InnerStarReference>,
sam_buf: Vec<u8>,
aln_buf: Vec<u8>,
fastq1: Vec<u8>,
Expand All @@ -167,7 +165,7 @@ enum AlignedRecords<'a> {
}

impl StarAligner {
fn new(reference: Arc<InnerStarReference>) -> StarAligner {
fn new(reference: Rc<InnerStarReference>) -> StarAligner {
let aligner = unsafe { bindings::init_aligner_from_ref(reference.as_ref().reference) };
let header_view = reference.as_ref().header_view.clone();

Expand Down
2 changes: 0 additions & 2 deletions star-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ pub struct StarRef {
_unused: [u8; 0],
}

unsafe impl Send for StarRef {}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct Aligner {
Expand Down

0 comments on commit 6cae26f

Please sign in to comment.