text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: adambudziak/shuffle path: /src/irs.rs
//! Implementation of the Inverse Riffle Shuffle algorithm.
//!
//! A Riffle Shuffle is a common algorithm used for mixing cards
//! (see [wiki](https://en.wikipedia.org/wiki/Riffle_shuffle_permutation)).
//!
//! Inverse Riffle Shuffle is an algorithm that h... | code_fim | hard | {
"lang": "rust",
"repo": "adambudziak/shuffle",
"path": "/src/irs.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn one_round<R>(
&self,
ctx: &mut Context<T>,
data: &mut Vec<T>,
rand_bit_iter: &mut InfiniteBitIter<R>,
) where
T: Clone,
R: RngCore + ?Sized,
{
let mut odd_count = 0;
for slot in ctx.bit_slots.iter_mut() {
*slot = (*... | code_fim | hard | {
"lang": "rust",
"repo": "adambudziak/shuffle",
"path": "/src/irs.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>losingDelimiter {
close: Delimiter,
},
UnexpectedEndOfToken {
expected: char,
},
UnexpectedToken {
expected: Vec<TokenKind>,
found: TokenKind,
},
UnknownAliasTarget {
alias: &'src str,
target: &'src str,
},
UnknownAttribute {
attribute: &'src str,
},
Unknown... | code_fim | hard | {
"lang": "rust",
"repo": "casey/just",
"path": "/src/compile_error_kind.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: casey/just path: /src/compile_error_kind.rs
use super::*;
#[derive(Debug, PartialEq)]
pub(crate) enum CompileErrorKind<'src> {
AliasInvalidAttribute {
alias: &'src str,
attr: Attribute,
},
AliasShadowsRecipe {
alias: &'src str,
recipe_line: usize,
},
BacktickShebang,
... | code_fim | hard | {
"lang": "rust",
"repo": "casey/just",
"path": "/src/compile_error_kind.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Writes a point to this SDC file.
///
/// # Examples
///
/// ```
/// use sdc::writer::Writer;
/// use sdc::point::Point;
/// let ref point = Point::new();
/// let mut file = Writer::from_path("/dev/null").unwrap();
/// file.write_point(point).unwrap();
pub fn... | code_fim | hard | {
"lang": "rust",
"repo": "gadomski/sdc-rs",
"path": "/src/writer.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gadomski/sdc-rs path: /src/writer.rs
//! Object for creating .sdc files.
use std::fs;
use std::io::{BufWriter, Write};
use std::path::Path;
use byteorder::{LittleEndian, WriteBytesExt};
use point::Point;
use result::Result;
/// An .sdc writer.
#[derive(Debug)]
pub struct Writer<W: Write> {
... | code_fim | hard | {
"lang": "rust",
"repo": "gadomski/sdc-rs",
"path": "/src/writer.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<W: Write> Writer<W> {
/// Creates a new writer, consuming the provided `Write`.
///
/// # Examples
///
/// ```
/// use std::fs::File;
/// use sdc::writer::Writer;
/// let writer = File::create("/dev/null").unwrap();
/// let writer = Writer::new(writer).unwrap();
... | code_fim | hard | {
"lang": "rust",
"repo": "gadomski/sdc-rs",
"path": "/src/writer.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lemonrock/bearssl-sys path: /src/bindgen/lib.rs
// This file is part of bearssl-sys. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/bearssl-sys/master/COPYRIGHT. No part of bearssl-... | code_fim | hard | {
"lang": "rust",
"repo": "lemonrock/bearssl-sys",
"path": "/src/bindgen/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>include!("constants.rs");
include!("functions.rs");
include!("statics.rs");
include!("structs.rs");
include!("types.rs");<|fim_prefix|>// repo: lemonrock/bearssl-sys path: /src/bindgen/lib.rs
// This file is part of bearssl-sys. It is subject to the license terms in the COPYRIGHT file found in the top-le... | code_fim | hard | {
"lang": "rust",
"repo": "lemonrock/bearssl-sys",
"path": "/src/bindgen/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>use ::core::clone::Clone;
use ::core::default::Default;
use ::core::fmt::Debug;
use ::core::fmt::Formatter;
use ::core::fmt::Result;
use ::core::marker::Copy;
use ::core::marker::PhantomData;
use ::core::mem::transmute;
use ::core::mem::zeroed;
use ::core::option::Option;
use ::libc::c_char;
use ::libc::c... | code_fim | medium | {
"lang": "rust",
"repo": "lemonrock/bearssl-sys",
"path": "/src/bindgen/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> //self.device.stop_recording()
// NYI
Ok(())
}
}
// Just some and audio dummy for now
pub struct Audio {
pub buffer: Vec<i16>,
pub samples_per_second: u32
}
impl Audio {
pub fn new_empty(samples_per_second: u32) -> Self {
Self{buffer: Vec::new(), samples_p... | code_fim | hard | {
"lang": "rust",
"repo": "lineCode/lily",
"path": "/src/audio.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lineCode/lily path: /src/audio.rs
use std::time::{SystemTime, Duration, UNIX_EPOCH};
use std::convert::TryInto;
use crate::vars::CLOCK_TOO_EARLY_MSG;
use hound;
use rodio::source::Source;
#[cfg(feature = "devel_cpal_rec")]
use cpal::traits::HostTrait;
pub struct PlayDevice {
device: rodi... | code_fim | hard | {
"lang": "rust",
"repo": "lineCode/lily",
"path": "/src/audio.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn read_for_ms(&mut self, milis: u16) -> Result<Option<&[i16]>, std::io::Error>;
fn start_recording(&mut self) -> Result<(), std::io::Error>;
fn stop_recording(&mut self) -> Result<(), std::io::Error>;
}
impl RecDevice {
pub fn new() -> Result<RecDevice, std::io::Error> {
//let ho... | code_fim | hard | {
"lang": "rust",
"repo": "lineCode/lily",
"path": "/src/audio.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn get_blob_stream(client: KeyClient) -> impl Stream<Item = Result<Vec<u8>, AzureError>> {
let stream = client
.stream_blob()
.with_container_name("foo")
.with_blob_name("foo")
.with_range(&Range::new(0, 2000))
.finalize();
stream
}<|fim_prefix|>// repo: tho... | code_fim | medium | {
"lang": "rust",
"repo": "thomastaylor312/blob-unpin",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thomastaylor312/blob-unpin path: /src/main.rs
use azure_core::errors::{AzureError, UnexpectedHTTPResult};
use azure_core::*;
use azure_storage::blob::prelude::*;
use azure_storage::client;
use azure_storage::key_client::KeyClient;
use prelude::Range;
use tokio_stream::{Stream, StreamExt};
#[to... | code_fim | hard | {
"lang": "rust",
"repo": "thomastaylor312/blob-unpin",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gcarq/romoulade path: /src/gb/cpu/registers.rs
use std::{convert, fmt};
/// Holds all CPU registers
#[derive(Copy, Clone)]
pub struct Registers {
pub a: u8,
pub b: u8,
pub c: u8,
pub d: u8,
pub e: u8,
pub f: FlagsRegister,
pub h: u8,
pub l: u8,
}
impl fmt::Displ... | code_fim | hard | {
"lang": "rust",
"repo": "gcarq/romoulade",
"path": "/src/gb/cpu/registers.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> (if flag.zero { 1 } else { 0 }) << ZERO_FLAG_BYTE_POSITION
| (if flag.negative { 1 } else { 0 }) << NEGATIVE_FLAG_BYTE_POSITION
| (if flag.half_carry { 1 } else { 0 }) << HALF_CARRY_FLAG_BYTE_POSITION
| (if flag.carry { 1 } else { 0 }) << CARRY_FLAG_BYTE_POSITIO... | code_fim | hard | {
"lang": "rust",
"repo": "gcarq/romoulade",
"path": "/src/gb/cpu/registers.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl convert::From<FlagsRegister> for u8 {
fn from(flag: FlagsRegister) -> u8 {
(if flag.zero { 1 } else { 0 }) << ZERO_FLAG_BYTE_POSITION
| (if flag.negative { 1 } else { 0 }) << NEGATIVE_FLAG_BYTE_POSITION
| (if flag.half_carry { 1 } else { 0 }) << HALF_CARRY_FLAG_BYT... | code_fim | hard | {
"lang": "rust",
"repo": "gcarq/romoulade",
"path": "/src/gb/cpu/registers.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lachlanwillis/rust-tutorials path: /variable-bindings/mutability.rs
// variable bindings are immutable by default but can be made mutable with the mut modifier
fn main() {
<|fim_suffix|> // error this is not okay
// _immutable_variable += 1;
}<|fim_middle|> let _immutable_variable = 1;
let... | code_fim | hard | {
"lang": "rust",
"repo": "lachlanwillis/rust-tutorials",
"path": "/variable-bindings/mutability.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // this is okay
mutable_variable += 1;
println!("after mutation: {}", mutable_variable);
// error this is not okay
// _immutable_variable += 1;
}<|fim_prefix|>// repo: lachlanwillis/rust-tutorials path: /variable-bindings/mutability.rs
// variable bindings are immutable by default but can be ... | code_fim | easy | {
"lang": "rust",
"repo": "lachlanwillis/rust-tutorials",
"path": "/variable-bindings/mutability.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let addr = "[::1]:50051".parse().unwrap();
let server = EchoServer::default();
let tls = ServerTlsConfig::new()
.identity(server_identity)
.client_ca_root(client_ca_cert);
Server::builder()
.tls_config(tls)?
.add_service(pb::echo_server::EchoServer::new(se... | code_fim | hard | {
"lang": "rust",
"repo": "SINHASantos/tonic",
"path": "/examples/src/tls_client_auth/server.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SINHASantos/tonic path: /examples/src/tls_client_auth/server.rs
pub mod pb {
tonic::include_proto!("grpc.examples.unaryecho");
}
use pb::{EchoRequest, EchoResponse};
use tonic::transport::{Certificate, Identity, Server, ServerTlsConfig};
use tonic::{Request, Response, Status};
type EchoRes... | code_fim | hard | {
"lang": "rust",
"repo": "SINHASantos/tonic",
"path": "/examples/src/tls_client_auth/server.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let tls = ServerTlsConfig::new()
.identity(server_identity)
.client_ca_root(client_ca_cert);
Server::builder()
.tls_config(tls)?
.add_service(pb::echo_server::EchoServer::new(server))
.serve(addr)
.await?;
Ok(())
}<|fim_prefix|>// repo: SINHASa... | code_fim | medium | {
"lang": "rust",
"repo": "SINHASantos/tonic",
"path": "/examples/src/tls_client_auth/server.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bsundsrud/tracer-rs path: /tracer-metrics/src/sample.rs
use std::hash::Hash;
use std::time::Duration;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum SampleValue {
/// Elapsed values can be added to Counters, Gauges, and Histograms
Elapsed(Duration),
/// Count values can be added to... | code_fim | hard | {
"lang": "rust",
"repo": "bsundsrud/tracer-rs",
"path": "/tracer-metrics/src/sample.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Create an `Elapsed` sample from the given key and duration
pub fn elapsed(key: T, duration: Duration) -> Sample<T> {
Sample::new(key, SampleValue::Elapsed(duration))
}
/// Create a `Count` sample from the given key and value
pub fn count(key: T, count: u64) -> Sample<T> {
... | code_fim | medium | {
"lang": "rust",
"repo": "bsundsrud/tracer-rs",
"path": "/tracer-metrics/src/sample.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Create a `Value` sample from the given key and value
pub fn value(key: T, value: u64) -> Sample<T> {
Sample::new(key, SampleValue::Value(value))
}
/// Get the key of this `Sample`
pub fn key(&self) -> T {
self.key.clone()
}
}<|fim_prefix|>// repo: bsundsrud/tra... | code_fim | hard | {
"lang": "rust",
"repo": "bsundsrud/tracer-rs",
"path": "/tracer-metrics/src/sample.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // The current progress percentage
let mut progress = 0;
'running: loop {
display.clear(BinaryColor::Off)?;
let sweep = progress as f32 * 360.0 / 100.0;
// Draw an arc with a 5px wide stroke.
Arc::new(Point::new(2, 2), 64 - 4, 90.0.deg(), sweep.deg())
... | code_fim | hard | {
"lang": "rust",
"repo": "BroderickCarlin/embedded-graphics",
"path": "/simulator/examples/progress.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BroderickCarlin/embedded-graphics path: /simulator/examples/progress.rs
//! # Example: Progress
//!
//! An example displaying a progress circle.
use embedded_graphics::{
fonts::{Font12x16, Text},
pixelcolor::BinaryColor,
prelude::*,
primitives::Arc,
style::{PrimitiveStyleBui... | code_fim | hard | {
"lang": "rust",
"repo": "BroderickCarlin/embedded-graphics",
"path": "/simulator/examples/progress.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Draw an arc with a 5px wide stroke.
Arc::new(Point::new(2, 2), 64 - 4, 90.0.deg(), sweep.deg())
.into_styled(arc_stroke)
.draw(&mut display)?;
// Draw centered text.
let text = format!("{}%", progress);
let width = text.len() as i32 * 12;... | code_fim | medium | {
"lang": "rust",
"repo": "BroderickCarlin/embedded-graphics",
"path": "/simulator/examples/progress.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jcc333/blood-sucker path: /src/mqtt/variable_header.rs
use std::io::{Error, ErrorKind, Read, Result, Write};
use mqtt::*;
pub type PacketId = u16;
#[derive(Copy, Clone)]
pub enum VariableHeader<'a> {
Connect {
username: bool,
password: bool,
will_retain: bool,
... | code_fim | medium | {
"lang": "rust",
"repo": "jcc333/blood-sucker",
"path": "/src/mqtt/variable_header.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a> Serde for VariableHeader<'a> {
fn ser(&self, sink: &mut Write) -> Result<usize> {
Err(Error::new(ErrorKind::Other, "not implemented"))
}
fn de(source: &mut Read) -> Result<(Self, usize)> {
Err(Error::new(ErrorKind::Other, "not implemented"))
}
}<|fim_prefix|>// re... | code_fim | hard | {
"lang": "rust",
"repo": "jcc333/blood-sucker",
"path": "/src/mqtt/variable_header.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oberzs/duku path: /src/image/properties.rs
// Oliver Berzs
// https://github.com/oberzs/duku
use crate::vk;
/// Color value representation mode.
///
/// Defines how textures should be sampled in the shader.
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum ColorSpace {
/// a linear rep... | code_fim | hard | {
"lang": "rust",
"repo": "oberzs/duku",
"path": "/src/image/properties.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub(crate) enum ImageLayout {
Undefined,
Depth,
Color,
ShaderColor,
ShaderDepth,
Present,
TransferSrc,
TransferDst,
}
impl ImageUsage {
pub(crate) fn combine(usages: &[Self]) -> vk::ImageUsageFlags {
usages.iter().fo... | code_fim | hard | {
"lang": "rust",
"repo": "oberzs/duku",
"path": "/src/image/properties.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>43, 216, 137, 52, 202, 158, 139, 187, 213, 194, 211, 74, 174, 179, 169, 41, 194, 141, 96, 79, 172, 48, 191, 205, 114, 80, 65, 63, 199, 82, 90, 63, 220, 87, 248, 41, 229, 143, 1, 222, 56, 133, 179, 86, 60, 173, 56, 220, 164, 88, 58, 250, 131, 72, 171, 169, 81, 61, 42, 106, 224, 50, 16, 162, 239, 226, 89, 1... | code_fim | hard | {
"lang": "rust",
"repo": "lefebvreb/super-simd",
"path": "/examples/demo.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lefebvreb/super-simd path: /examples/demo.rs
extern crate super_simd;
use super_simd::u8x512;
const DATA1: [u8; 512] = [172, 99, 198, 144, 140, 233, 214, 7, 238, 150, 184, 62, 183, 97, 122, 128, 5, 70, 146, 46, 73, 148, 206, 17, 15, 18, 116, 25, 34, 116, 155, 87, 49, 246, 121, 104, 191, 124, 93... | code_fim | hard | {
"lang": "rust",
"repo": "lefebvreb/super-simd",
"path": "/examples/demo.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lilydjwg/filequeue path: /src/kafkasink.rs
use std::sync::mpsc;
use std::collections::HashMap;
use std::time::Duration;
use rdkafka::config::ClientConfig;
use rdkafka::producer::{BaseProducer, BaseRecord, DefaultProducerContext};
<|fim_suffix|> Ok(KafkaSink {
client: config.create()?,... | code_fim | hard | {
"lang": "rust",
"repo": "lilydjwg/filequeue",
"path": "/src/kafkasink.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct KafkaSink {
client: BaseProducer<DefaultProducerContext>,
topic: String,
}
impl KafkaSink {
pub fn new<S: Into<String>>(topic: S, confmap: HashMap<String,String>)
-> Result<Self> {
let mut config = ClientConfig::new();
for (k, v) in confmap {
config.set(&k, &v);
}
... | code_fim | medium | {
"lang": "rust",
"repo": "lilydjwg/filequeue",
"path": "/src/kafkasink.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn connect_property_is_for_audio_device_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_is_for_video_device_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
}
impl<O: IsA<UserMediaPermissionRequest> + IsA<glib::object::Object>> UserMediaPermissi... | code_fim | hard | {
"lang": "rust",
"repo": "antoyo/webkit2gtk-rs",
"path": "/src/auto/user_media_permission_request.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn connect_property_is_for_video_device_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::is-for-video-device",
transmute(no... | code_fim | hard | {
"lang": "rust",
"repo": "antoyo/webkit2gtk-rs",
"path": "/src/auto/user_media_permission_request.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: antoyo/webkit2gtk-rs path: /src/auto/user_media_permission_request.rs
// This file was generated by gir (https://github.com/gtk-rs/gir @ fbb95f4)
// from gir-files (https://github.com/gtk-rs/gir-files @ 77d1f70)
// DO NOT EDIT
use PermissionRequest;
use ffi;
use glib;
use glib::StaticType;
use ... | code_fim | hard | {
"lang": "rust",
"repo": "antoyo/webkit2gtk-rs",
"path": "/src/auto/user_media_permission_request.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: basiliqio/ciboulette path: /src/query/tests/meta.rs
use super::*;
#[test]
fn simple() {
let (bag, builder) = setup(r#"hahaha=hohoho"#);
let res: CibouletteQueryParameters = builder
.build(&bag, bag.get_type("peoples").unwrap().clone())
.expect("to build correctly");
... | code_fim | hard | {
"lang": "rust",
"repo": "basiliqio/ciboulette",
"path": "/src/query/tests/meta.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("The value at 50 is now '{:?}'!", sp[49].pos);
}
fn test_scene(){
let mut scene = Scene::new(720,480);
scene.compute().unwrap();
let screen = scene.get_screen();
for i in 172800..172805 {
print!("{}-",screen[i])
}
}
fn main() {
println!("{}",std::mem::size_o... | code_fim | hard | {
"lang": "rust",
"repo": "ykafia/rust_gpu_raytracer",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ykafia/rust_gpu_raytracer path: /src/main.rs
use std::time::Instant;
use nalgebra::Rotation3;
use ocl::{Buffer, OclPrm, ProQue, prm::{Float2, Float3}};
// mod maths;
// use maths::*;
mod util;
use util::*;
mod graphics;
use graphics::*;
use window::window;
mod window;
fn trivial() {
//... | code_fim | hard | {
"lang": "rust",
"repo": "ykafia/rust_gpu_raytracer",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut scene = Scene::new(720,480);
scene.compute().unwrap();
let screen = scene.get_screen();
for i in 172800..172805 {
print!("{}-",screen[i])
}
}
fn main() {
println!("{}",std::mem::size_of::<Camera>());
// trivial();
// test_scene();
window(&mut Scene::new... | code_fim | hard | {
"lang": "rust",
"repo": "ykafia/rust_gpu_raytracer",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JRF63/windows-spotlight path: /src/datetime.rs
extern crate winapi;
use winapi::shared::minwindef::FILETIME;
use winapi::um::minwinbase::SYSTEMTIME;
use winapi::um::timezon<|fim_suffix|>TIME, &mut systime) } == 0 {
panic!()
}
format!("{}{:02}{:02}", systime.wYear, systime.wMonth... | code_fim | hard | {
"lang": "rust",
"repo": "JRF63/windows-spotlight",
"path": "/src/datetime.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>TIME, &mut systime) } == 0 {
panic!()
}
format!("{}{:02}{:02}", systime.wYear, systime.wMonth, systime.wDay)
}<|fim_prefix|>// repo: JRF63/windows-spotlight path: /src/datetime.rs
extern crate winapi;
use winapi::shared::minwindef::FILETIME;
use winapi::um::minwinbase::SYSTEMTIME;
use wi... | code_fim | hard | {
"lang": "rust",
"repo": "JRF63/windows-spotlight",
"path": "/src/datetime.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[gml::get(caption_score)]
pub fn get_caption_score(&self) -> Symbol { self.caption_score }
#[gml::set(caption_score)]
pub fn set_caption_score(&mut self, value: Symbol) { self.caption_score = value; }
#[gml::get(caption_lives)]
pub fn get_caption_lives(&self) -> Symbol { se... | code_fim | hard | {
"lang": "rust",
"repo": "rpjohnst/dejavu",
"path": "/runner/src/world/score.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rpjohnst/dejavu path: /runner/src/world/score.rs
use gml::symbol::Symbol;
#[derive(Default)]
pub struct State {
pub score: f32,
pub lives: f32,
pub health: f32,
pub show_score: bool,
pub show_lives: bool,
pub show_health: bool,
pub caption_score: Symbol... | code_fim | hard | {
"lang": "rust",
"repo": "rpjohnst/dejavu",
"path": "/runner/src/world/score.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: johannes-mueller/pugl-sys path: /build.rs
extern crate bindgen;
use std::process::Command;
use std::fs;
use std::env;
use std::path::PathBuf;
fn main() {
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
Command::new("python")
.current_dir("pugl")
.env("CFLAG... | code_fim | hard | {
"lang": "rust",
"repo": "johannes-mueller/pugl-sys",
"path": "/build.rs",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut bindings_string ="#[cfg(test)] use mockall::automock;\n"
.to_owned();
bindings_string.push_str("#[cfg_attr(test, automock)]\npub(crate) mod pffi {\nuse super::*;\n");
bindings_string.push_str(&bindgen::Builder::default()
.header("pugl/include/pugl/p... | code_fim | hard | {
"lang": "rust",
"repo": "johannes-mueller/pugl-sys",
"path": "/build.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|>of_items.entry(*item).or_insert(0);
*count += 1;
}
let mut output = 0;
for (&key, &value) in &count_of_items {
if value == repeated_times as i32 {
output = key;
}
}
output
}
}<|fim_prefix|>// repo: bing050802/l... | code_fim | medium | {
"lang": "rust",
"repo": "bing050802/leetcode-rust-repo",
"path": "/961/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>_of_items {
if value == repeated_times as i32 {
output = key;
}
}
output
}
}<|fim_prefix|>// repo: bing050802/leetcode-rust-repo path: /961/main.rs
impl Solution {
pub fn repeated_n_times(a: Vec<i32>) -> i32 {
use std::collections::H... | code_fim | medium | {
"lang": "rust",
"repo": "bing050802/leetcode-rust-repo",
"path": "/961/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bing050802/leetcode-rust-repo path: /961/main.rs
impl Solution {
pub fn repeated_n_times(a: Vec<i32>) -> i32 {
use std::collections::HashMap;
let repeated_times = a.len() / 2;
let mut count_of_items: HashMap<i32, i32> = HashMap::new();
for item in &a {
... | code_fim | medium | {
"lang": "rust",
"repo": "bing050802/leetcode-rust-repo",
"path": "/961/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[allow(dead_code)]
pub fn white() -> Self {
Color{
r: 255,
g : 255,
b: 255
}
}
#[allow(dead_code)]
pub fn red() -> Self{
Color{ r: 255, g : 0, b: 0, }
}
#[allow(dead_code)]
pub fn green() -> Self{
... | code_fim | hard | {
"lang": "rust",
"repo": "Hperigo/rust-raytracer",
"path": "/src/color.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Hperigo/rust-raytracer path: /src/color.rs
#[derive(Debug, Clone)]
pub struct Color<T>{
pub r : T,
pub g : T,
pub b : T,
}
<|fim_suffix|> #[allow(dead_code)]
pub fn white() -> Self {
Color{
r: 255,
g : 255,
b: 255
}
... | code_fim | hard | {
"lang": "rust",
"repo": "Hperigo/rust-raytracer",
"path": "/src/color.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rstropek/rust-samples path: /const_fn/src/main.rs
// Further readings:
// What's new in Rust 1.61: https://blog.rust-lang.org/2022/05/19/Rust-1.61.0.html
// Tracking issue for const fn: https://github.com/rust-lang/rust/issues/57563
// Constant items in Rust docs: https://doc.rust-lang.org/refer... | code_fim | hard | {
"lang": "rust",
"repo": "rstropek/rust-samples",
"path": "/const_fn/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Note that for loop is not (yet) allowed in const functions.
// We have to use while instead.
while i < x.len() {
buffer[position_in_buffer] = x[i];
position_in_buffer += 1;
i += 1;
}
remaining = tail;
}
Buf(buffer)
}
... | code_fim | hard | {
"lang": "rust",
"repo": "rstropek/rust-samples",
"path": "/const_fn/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> "woof"
}
}
// Brand new (1.61): Arguments and return values for const fns
// now support impl trait.
const fn favorite_animal() -> impl Animal {
Cat {}
}
// Brand new (1.61): Arguments and return values for const fns
// now support dyn trait.
const fn animal_by_sound<'a>(can_purr: bool) ... | code_fim | hard | {
"lang": "rust",
"repo": "rstropek/rust-samples",
"path": "/const_fn/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn plus(&self, v: &Vector) -> Vector {
return Vector::new(self.x + v.x, self.y + v.y);
}
pub fn plus_equals(&mut self, v: &Vector) {
self.x += v.x;
self.y += v.y;
}
pub fn minus(&self, v: &Vector) -> Vector {
return Vector::new(self.x - v.x, self.y... | code_fim | hard | {
"lang": "rust",
"repo": "wreganpdx/ApeRust",
"path": "/src/pdx/ape/vector.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wreganpdx/ApeRust path: /src/pdx/ape/vector.rs
/*
William Regan
Tyler Pelham
Portland State University
Rust Programming 510
Final Project
*/
use std::f64;
/**
* Vector.rs
*
* Summary: Simple two dimensional object for doing math on x and y coords
*
* For more information, see https://gith... | code_fim | hard | {
"lang": "rust",
"repo": "wreganpdx/ApeRust",
"path": "/src/pdx/ape/vector.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fossabot/fiber-mark path: /src/constants.rs
#[allow(dead_code)]
#[cfg(windows)]
pub(crate) const LINE_ENDING: &'static str = "\r\n";
<|fim_suffix|>crate) const LINE_ENDING: &'static str = "\n";<|fim_middle|>#[allow(dead_code)]
#[cfg(not(windows))]
pub( | code_fim | easy | {
"lang": "rust",
"repo": "fossabot/fiber-mark",
"path": "/src/constants.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>crate) const LINE_ENDING: &'static str = "\n";<|fim_prefix|>// repo: fossabot/fiber-mark path: /src/constants.rs
#[allow(dead_code)]
#[cfg(windows)]
pub(crate) const LINE_ENDING: &'static str = "\r\n";
<|fim_middle|>#[allow(dead_code)]
#[cfg(not(windows))]
pub( | code_fim | easy | {
"lang": "rust",
"repo": "fossabot/fiber-mark",
"path": "/src/constants.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: brl/citadel-tools path: /citadel-installer-ui/src/error.rs
use std::result;
<|fim_suffix|>#[derive(Debug)]
pub enum Error {
Dbus(dbus::Error),
Builder(String),
}<|fim_middle|>use dbus;
pub type Result<T> = result::Result<T, Error>;
| code_fim | easy | {
"lang": "rust",
"repo": "brl/citadel-tools",
"path": "/citadel-installer-ui/src/error.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug)]
pub enum Error {
Dbus(dbus::Error),
Builder(String),
}<|fim_prefix|>// repo: brl/citadel-tools path: /citadel-installer-ui/src/error.rs
use std::result;
<|fim_middle|>use dbus;
pub type Result<T> = result::Result<T, Error>;
| code_fim | easy | {
"lang": "rust",
"repo": "brl/citadel-tools",
"path": "/citadel-installer-ui/src/error.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn identify<P: AsRef<Path>>(path: P) -> ImageInfo {
let out = Command::new("identify")
.arg(path.as_ref())
.output()
.unwrap();
assert!(out.status.success());
let stdout = str::from_utf8(&out.stdout).unwrap();
let re = Regex::new(r" (\d+)x(\d+) ").unwrap();
... | code_fim | medium | {
"lang": "rust",
"repo": "ealasu/image-tools",
"path": "/imagemagick/src/identify.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ealasu/image-tools path: /imagemagick/src/identify.rs
use std::str;
use std::path::Path;
use std::process::Command;
use regex::Regex;
<|fim_suffix|>pub fn identify<P: AsRef<Path>>(path: P) -> ImageInfo {
let out = Command::new("identify")
.arg(path.as_ref())
.output()
... | code_fim | medium | {
"lang": "rust",
"repo": "ealasu/image-tools",
"path": "/imagemagick/src/identify.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fimbault/adventofcode-rs path: /src/aoc2020/day05.rs
#![allow(dead_code)]
use crate::puzzle::get_puzzle;
pub fn challenge() {
let input = get_puzzle(2020, 5).unwrap();
let mut seats: Vec<u32> = vec![];
input
.lines()
.for_each(|line| {
seats.push(decode... | code_fim | medium | {
"lang": "rust",
"repo": "fimbault/adventofcode-rs",
"path": "/src/aoc2020/day05.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
fn decode_seat(value: &str) -> u32 {
// transform into binary string
let bin: String = value.chars()
.map(|x| match x {
'B' => '1',
'F' => '0',
'R' => '1',
'L' => '0',
_ => unreachable!(),
}).collect();
// now convert from binary to decimal... | code_fim | medium | {
"lang": "rust",
"repo": "fimbault/adventofcode-rs",
"path": "/src/aoc2020/day05.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
fn find_empty_seat(seats: &mut Vec<u32>) -> u32 {
let mut my_seat = 0;
for s in *seats.first().unwrap()..*seats.last().unwrap()
{
if !seats.contains(&s) { my_seat = s; }
}
my_seat
}
#[test]
fn day5_works() {
let result = decode_seat("BFFFBBFRRR") == 567 &&
decode... | code_fim | hard | {
"lang": "rust",
"repo": "fimbault/adventofcode-rs",
"path": "/src/aoc2020/day05.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: algon-320/Kyopro-Ratings path: /src/contest_service/atcoder.rs
use super::Color;
use super::Rating;
use crate::cache::FreshCache;
use crate::util::japan_tomorrow;
lazy_static::lazy_static! {
static ref CACHE: FreshCache<Option<Rating>> = FreshCache::new();
}
pub const NAME: &str = "atcoder... | code_fim | medium | {
"lang": "rust",
"repo": "algon-320/Kyopro-Ratings",
"path": "/src/contest_service/atcoder.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let document = scraper::Html::parse_document(&html);
let selector = scraper::Selector::parse(ATCODER_RATING_CSS_SELECTOR).ok()?;
let span = document.select(&selector).next()?;
let rating_str = span.text().next()?;
let value = rating_str.parse::<i64>().ok()?;
... | code_fim | hard | {
"lang": "rust",
"repo": "algon-320/Kyopro-Ratings",
"path": "/src/contest_service/atcoder.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ritobanrc/aoc2020 path: /src/day10.rs
use std::collections::HashMap;
use itertools::Itertools;
pub fn part1(input: String) -> usize {
let mut adapters: Vec<u32> = input.lines().map(|x| x.parse().unwrap()).collect();
adapters.sort_unstable();
let mut ones = adapters
.iter()... | code_fim | hard | {
"lang": "rust",
"repo": "ritobanrc/aoc2020",
"path": "/src/day10.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> memo.insert(last, total);
total
}
count_possibilites(start, end, &graph, &mut memo)
}
#[test]
fn day10_test() {
let input = "
16
10
15
5
1
11
7
19
6
12
4
"
.trim();
assert_eq!(35, part1(input.to_owned()));
//assert_eq!(8, part2(input.to_owned()));
l... | code_fim | hard | {
"lang": "rust",
"repo": "ritobanrc/aoc2020",
"path": "/src/day10.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> //calculate local coordinate system
//let forward = (self.target - self.position).normalised();
let forward = self.direction;
let right = self.right * scale;
let up = self.up * -scale; //negative because (0,0) is TOP right
let center = self.position + forwa... | code_fim | hard | {
"lang": "rust",
"repo": "DasCapschen/rustrace",
"path": "/src/camera.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let focus_dist = match self.focus {
Focus::AutoFocus => {
2.0 //TODO!
}
Focus::Distance(d) => d,
};
//width of our screen at focal distance
let focal_width = 2.0 * self.tan_half_fov * focus_dist;
//figure out by ... | code_fim | hard | {
"lang": "rust",
"repo": "DasCapschen/rustrace",
"path": "/src/camera.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DasCapschen/rustrace path: /src/camera.rs
use crate::math::vec3::Vec3;
use crate::ray::Ray;
#[derive(Debug, Copy, Clone, PartialEq, PartialOrd)]
pub struct CropFactor(f32);
impl CropFactor {
pub const FULL_FORMAT: Self = Self(1.0_f32);
pub const APSC: Self = Self(1.525_f32);
pub con... | code_fim | hard | {
"lang": "rust",
"repo": "DasCapschen/rustrace",
"path": "/src/camera.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> use kvproto::kvrpcpb::ApiVersion;
use sst_importer::SstImporter;
use tempfile::TempDir;
pub fn create_tmp_importer() -> (TempDir, Arc<SstImporter>) {
let dir = TempDir::new().unwrap();
let importer = Arc::new(
SstImporter::new(&Default::default(), dir.path(), N... | code_fim | medium | {
"lang": "rust",
"repo": "baiyuqing/tikv",
"path": "/components/raftstore-v2/src/operation/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
pub mod test_util {
use std::sync::Arc;
use kvproto::kvrpcpb::ApiVersion;
use sst_importer::SstImporter;
use tempfile::TempDir;
pub fn create_tmp_importer() -> (TempDir, Arc<SstImporter>) {
let dir = TempDir::new().unwrap();
let importer = Arc::new(
... | code_fim | medium | {
"lang": "rust",
"repo": "baiyuqing/tikv",
"path": "/components/raftstore-v2/src/operation/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: baiyuqing/tikv path: /components/raftstore-v2/src/operation/mod.rs
// Copyright 2022 TiKV Project Authors. Licensed under Apache-2.0.
mod bucket;
mod command;
mod life;
mod pd;
mod query;
mod ready;
mod txn_ext;
pub use command::{
AdminCmdResult, ApplyFlowControl, CatchUpLogs, CommittedEnt... | code_fim | medium | {
"lang": "rust",
"repo": "baiyuqing/tikv",
"path": "/components/raftstore-v2/src/operation/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Type privacy should prevent use of these in other crates, so we shouldn't
// need a stability annotation.
fn private_function() {}
struct PrivateStruct { f: () }
enum PrivateEnum { V }
union PrivateUnion { g: () }
trait PrivateTrait {}
#[stable(feature = "test", since = "1.0.0")]
pub macro m() {}
fn ... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/definition-reachable/private-types.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/definition-reachable/private-types.rs
// Check that type privacy is taken into account when considering reachability
// check-pass
<|fim_suffix|>// Type privacy should prevent use of these in other crates, so we shouldn't
// need a stability a... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/definition-reachable/private-types.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kamojiro/atcoderall path: /beginner/007/c/src/main.rs
#![allow(non_snake_case)]
use std::collections::VecDeque;
fn main() {
let s = std::io::stdin();
let mut sc = Scanner { stdin: s.lock() };
let r :usize = sc.read();
let c :usize = sc.read();
let mut sy:usize = sc.read();
... | code_fim | hard | {
"lang": "rust",
"repo": "kamojiro/atcoderall",
"path": "/beginner/007/c/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match parse_dot_atom(buf, writer) {
Ok((_, dot_atom)) => parse_ok(buf, dot_atom.len()),
Err(e) => match *e.kind() {
ErrorKind::Parsing => parse_domain_literal(buf, writer),
_ => Err(e),
},
}
}
// obs-dtext = obs-NO-WS-CTL / quoted-pair
// do... | code_fim | hard | {
"lang": "rust",
"repo": "little-dude/imf",
"path": "/src/address.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: little-dude/imf path: /src/address.rs
use errors::{parse_ok, Error, ErrorKind, ParseResult};
use std::io::Write;
use atom::{parse_atom, parse_dot_atom};
use whitespaces::{read_cfws, read_fws, replace_fws};
use quoted_string::{parse_quoted_string, read_quoted_string};
use common::parse_phrase as ... | code_fim | hard | {
"lang": "rust",
"repo": "little-dude/imf",
"path": "/src/address.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // read [CFWS]
let mut i = if let Ok((_, cfws)) = read_cfws(buf) {
cfws.len()
} else {
0
};
// read "["
if i >= buf.len() || buf[i] != b'[' {
return Err(ErrorKind::Parsing.into());
}
i += 1;
// read *([FWS] dtext)
while i < buf.len() {
... | code_fim | hard | {
"lang": "rust",
"repo": "little-dude/imf",
"path": "/src/address.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>= 1;
break;
}
}
}
delete
}
}<|fim_prefix|>// repo: EduardoSantos7/Algorithms4fun path: /Leetcode/944. Delete Columns to Make Sorted/solution.rs
impl Solution {
pub fn min_deletion_size(strs: Vec<String>) -> i32 {
let mut dele... | code_fim | hard | {
"lang": "rust",
"repo": "EduardoSantos7/Algorithms4fun",
"path": "/Leetcode/944. Delete Columns to Make Sorted/solution.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EduardoSantos7/Algorithms4fun path: /Leetcode/944. Delete Columns to Make Sorted/solution.rs
impl Solution {
pub fn min_deletion_size(strs: Vec<String>) -> i32 {
let mut delete<|fim_suffix|>= 1;
break;
}
}
}
delete
}... | code_fim | hard | {
"lang": "rust",
"repo": "EduardoSantos7/Algorithms4fun",
"path": "/Leetcode/944. Delete Columns to Make Sorted/solution.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let protein: Vec<_> = protein.chars().collect();
let mut spectrum = Vec::new();
for i in 0..protein.len() {
spectrum.push(protein[i..].iter().map(|c| aa_to_mass[c]).sum::<f64>());
spectrum.push(protein[..i].iter().map(|c| aa_to_mass[c]).sum::<f64>());
}
spectrum
}<|fim_... | code_fim | medium | {
"lang": "rust",
"repo": "Ninjani/rosalind",
"path": "/s_prsm/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ninjani/rosalind path: /s_prsm/src/lib.rs
use std::collections::HashMap;
use anyhow::Error;
use s_conv::{get_max_multiplicity, get_minkowski_difference};
use std::path::Path;
/// Matching a Spectrum to a Protein
///
/// Given: A positive integer n followed by a collection of n protein strings... | code_fim | medium | {
"lang": "rust",
"repo": "Ninjani/rosalind",
"path": "/s_prsm/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // proto: void QGraphicsLayout::widgetEvent(QEvent * e);
impl /*struct*/ QGraphicsLayout {
pub fn widgetEvent<RetType, T: QGraphicsLayout_widgetEvent<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.widgetEvent(self);
// return 1;
}
}
pub trait QGraphicsLayout_widgetE... | code_fim | hard | {
"lang": "rust",
"repo": "kitech/qt.rs",
"path": "/src/widgets/qgraphicslayout.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kitech/qt.rs path: /src/widgets/qgraphicslayout.rs
// auto generated, do not modify.
// created: Mon Feb 22 23:57:02 2016
// src-file: /QtWidgets/qgraphicslayout.h
// dst-file: /src/widgets/qgraphicslayout.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections... | code_fim | hard | {
"lang": "rust",
"repo": "kitech/qt.rs",
"path": "/src/widgets/qgraphicslayout.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: konradmoesch/rust_asio path: /examples/daytime7_a_combined_tcp_udp_asynchronous_daytime_server.rs
extern crate asyncio;
extern crate time;
use std::io;
use asyncio::*;
use asyncio::ip::*;
use asyncio::socket_base::*;
struct DaytimeTcp {
soc: TcpSocket,
buf: String,
}
impl DaytimeTcp {... | code_fim | hard | {
"lang": "rust",
"repo": "konradmoesch/rust_asio",
"path": "/examples/daytime7_a_combined_tcp_udp_asynchronous_daytime_server.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn on_send(daytime: Strand<Self>, res: io::Result<usize>) {
if let Ok(_) = res {
daytime.soc.async_receive_from(
&mut daytime.get().buf,
0,
daytime.wrap(Self::on_receive),
);
}
}
}
fn main() {
let ctx = &I... | code_fim | hard | {
"lang": "rust",
"repo": "konradmoesch/rust_asio",
"path": "/examples/daytime7_a_combined_tcp_udp_asynchronous_daytime_server.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in bus_stops {
bus = bus + i.0 - i.1;
}
return bus;
}<|fim_prefix|>// repo: stuartstein777/CodeWars path: /7KYU/Number of People in the Bus/solution.rs
fn number(bus_stops:&[(i32,i32)]) -> i32 {
<|fim_middle|> let mut bus: i32 = 0;
| code_fim | easy | {
"lang": "rust",
"repo": "stuartstein777/CodeWars",
"path": "/7KYU/Number of People in the Bus/solution.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stuartstein777/CodeWars path: /7KYU/Number of People in the Bus/solution.rs
fn number(bus_stops:&[(i32,i32)]) -> i32 {
<|fim_suffix|> for i in bus_stops {
bus = bus + i.0 - i.1;
}
return bus;
}<|fim_middle|> let mut bus: i32 = 0;
| code_fim | easy | {
"lang": "rust",
"repo": "stuartstein777/CodeWars",
"path": "/7KYU/Number of People in the Bus/solution.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gong023/rust-tutorial path: /generics.rs
fn print_vec<T: std::fmt::Show>(v: &[T]) {
for i in v.iter() {
println!("{}", i)
}
}
<|fim_suffix|> let vec = [1i, 2i, 3i];
print_vec(vec);
let str_vec = ["hey", "hi", "hello"];
print_vec(str_vec);
}<|fim_middle|>fn main... | code_fim | easy | {
"lang": "rust",
"repo": "gong023/rust-tutorial",
"path": "/generics.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> print_vec(vec);
let str_vec = ["hey", "hi", "hello"];
print_vec(str_vec);
}<|fim_prefix|>// repo: gong023/rust-tutorial path: /generics.rs
fn print_vec<T: std::fmt::Show>(v: &[T]) {
for i in v.iter() {
println!("{}", i)
}
}
fn main() {
<|fim_middle|> let vec = [1i, 2i, 3... | code_fim | easy | {
"lang": "rust",
"repo": "gong023/rust-tutorial",
"path": "/generics.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nagya11/rust-elasticsearch path: /examples/main.rs
extern crate elasticsearch;
use elasticsearch::JsonObjectBuilder;
fn main() {
let mut client = elasticsearch::Client::new("http://localhost:9200");
/*
println!("{}\n", client.transport.head("/"));
println!("{}\n", client.transp... | code_fim | hard | {
"lang": "rust",
"repo": "nagya11/rust-elasticsearch",
"path": "/examples/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("delete that document with a query");
println!("{}\n", client.prepare_delete_by_query()
.set_indices(vec!["test".to_string()])
.set_source(JsonObjectBuilder::new()
.insert_object("term".to_string(), |bld| bld.insert("bar".to_string(), "lala".to_string()))
.... | code_fim | hard | {
"lang": "rust",
"repo": "nagya11/rust-elasticsearch",
"path": "/examples/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("{}\n", client.prepare_search()
.set_indices(vec!["test".to_string()])
.set_source(JsonObjectBuilder::new()
.insert("fields".to_string(), vec!["foo".to_string(), "bar".to_string()])
.unwrap()
)
.execute());
println!("try to delete that document... | code_fim | hard | {
"lang": "rust",
"repo": "nagya11/rust-elasticsearch",
"path": "/examples/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.