Skip to content

Commit

Permalink
Replace generic with concrete
Browse files Browse the repository at this point in the history
  • Loading branch information
amab8901 committed Feb 19, 2023
1 parent 181f286 commit 374e56d
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions applications/test_channel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ macro_rules! receive_count {
() => (RECEIVE_COUNT.load(Ordering::SeqCst))
}

pub fn main<T:Send>(args: Vec<String>) -> isize {
pub fn main(args: Vec<String>) -> isize {
let mut opts = Options::new();
opts.optflag("h", "help", "print this help menu");
opts.optflag("v", "verbose", "enable verbose output");
Expand Down Expand Up @@ -102,7 +102,7 @@ pub fn main<T:Send>(args: Vec<String>) -> isize {
}


match rmain::<T>(matches) {
match rmain(matches) {
Ok(_) => 0,
Err(e) => {
println!("Error: {}", e);
Expand All @@ -111,7 +111,7 @@ pub fn main<T:Send>(args: Vec<String>) -> isize {
}
}

fn rmain<T:Send>(matches: Matches) -> Result<(), &'static str> {
fn rmain(matches: Matches) -> Result<(), &'static str> {
let mut did_something = false;

// If the user has specified panic instances as 'val', 'send_panic_pont' will be 'Some(val)'.
Expand Down Expand Up @@ -153,26 +153,26 @@ fn rmain<T:Send>(matches: Matches) -> Result<(), &'static str> {
if matches.opt_present("o") {
did_something = true;
println!("Running drop_last_sender test in oneshot mode.");
drop_last_sender_oneshot::<T>()?;
drop_last_sender_oneshot()?;
}
if matches.opt_present("m") {
did_something = true;
println!("Running drop_last_sender test in multiple mode.");
drop_last_sender_multiple::<T>()?;
drop_last_sender_multiple()?;
}
}

if matches.opt_present("R") {
if matches.opt_present("o") {
did_something = true;
println!("Running drop_last_receiver test in oneshot mode.");
drop_last_receiver_oneshot::<T>()?;
drop_last_receiver_oneshot()?;

}
if matches.opt_present("m") {
did_something = true;
println!("Running drop_last_receiver test in multiple mode.");
drop_last_receiver_multiple::<T>()?;
drop_last_receiver_multiple()?;

}
}
Expand Down Expand Up @@ -436,8 +436,8 @@ const USAGE: &'static str = "Usage: test_channel OPTION ARG
Provides a selection of different tests for channel-based communication.";

/// Create one sender and one receiver. Drop the receiver. Channel should be marked as disconnected.
fn drop_last_sender_oneshot<T:Send>() -> Result<(), &'static str> {
let (sender, receiver) = async_channel::new_channel::<T>(2);
fn drop_last_sender_oneshot() -> Result<(), &'static str> {
let (sender, receiver) = async_channel::new_channel::<String>(2);
drop(sender);

if receiver.channel_status() != async_channel::ChannelStatus::SenderDisconnected {
Expand All @@ -449,9 +449,9 @@ fn drop_last_sender_oneshot<T:Send>() -> Result<(), &'static str> {
}

/// Create two receivers and one sender. Drop the sender. Channel should be marked as disconnected.
fn drop_last_sender_multiple<T:Send>() -> Result<(), &'static str> {
fn drop_last_sender_multiple() -> Result<(), &'static str> {
let (sender, receiver) = async_channel::new_channel(2);
let receiver2: async_channel::Receiver<T> = receiver.clone();
let receiver2: async_channel::Receiver<String> = receiver.clone();
drop(sender);

if receiver.channel_status() != async_channel::ChannelStatus::SenderDisconnected {
Expand All @@ -467,8 +467,8 @@ fn drop_last_sender_multiple<T:Send>() -> Result<(), &'static str> {
}

/// Create one sender and one receiver. Drop the receiver. Channel should be marked as disconnected.
fn drop_last_receiver_oneshot<T:Send>() -> Result<(), &'static str> {
let (sender, receiver) = async_channel::new_channel::<T>(2);
fn drop_last_receiver_oneshot() -> Result<(), &'static str> {
let (sender, receiver) = async_channel::new_channel::<String>(2);
drop(receiver);

if sender.channel_status() != async_channel::ChannelStatus::ReceiverDisconnected {
Expand All @@ -479,9 +479,9 @@ fn drop_last_receiver_oneshot<T:Send>() -> Result<(), &'static str> {
}

/// Create two senders and one receiver. Drop the receiver. Channel should be marked as disconnected.
fn drop_last_receiver_multiple<T:Send>() -> Result<(), &'static str> {
fn drop_last_receiver_multiple() -> Result<(), &'static str> {
let (sender, receiver) = async_channel::new_channel(2);
let sender2: async_channel::Sender<T> = sender.clone();
let sender2: async_channel::Sender<String> = sender.clone();
drop(receiver);

if sender.channel_status() != async_channel::ChannelStatus::ReceiverDisconnected {
Expand Down

0 comments on commit 374e56d

Please sign in to comment.