text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: audreyfeldroy/diamond-types path: /src/range_tree/root.rs
pub fn new() -> Pin<Box<Self>> {
let mut tree = Box::pin(Self {
count: I::IndexOffset::default(),
root: unsafe { Node::new_leaf() },
last_cursor: Cell::new(None),
_pin: marker::Phan... | code_fim | hard | {
"lang": "rust",
"repo": "audreyfeldroy/diamond-types",
"path": "/src/range_tree/root.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fanderzon/talks path: /2016-06-13-getting-started-with-rust/assets/code/result.rs
impl Person {
// ...
fn add_age(&mut self, age: u8) -> Result<u8, String>{
if age > 100 {
Err("Please enter a valid age".to_string())
} else {
self.age = Some(age);
Ok(age)
... | code_fim | easy | {
"lang": "rust",
"repo": "fanderzon/talks",
"path": "/2016-06-13-getting-started-with-rust/assets/code/result.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // ...
fredrik.add_age(33);
match fredrik.add_age(133) {
Err(reason) => println!("Error: {}", reason),
Ok(new_age) => println!("Age set to {}", new_age),
}
}<|fim_prefix|>// repo: fanderzon/talks path: /2016-06-13-getting-started-with-rust/assets/code/result.rs
impl Perso... | code_fim | medium | {
"lang": "rust",
"repo": "fanderzon/talks",
"path": "/2016-06-13-getting-started-with-rust/assets/code/result.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_plotdata_pykwargs(&self, py: Python<'py>, mpl: &'py PyModule) -> &PyDict {
match self {
PlotData::Scatter(scatter_plot) => scatter_plot.get_plot_kwargs(py, mpl), //placeholder
PlotData::PlotSurface(surface_plot) => surface_plot.get_plot_kwargs(py, mpl),
... | code_fim | hard | {
"lang": "rust",
"repo": "PhilDK1/rustmplotlib",
"path": "/src/figax/plots.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PhilDK1/rustmplotlib path: /src/figax/plots.rs
use pyo3::prelude::*;
use pyo3::types::*;
// use crate::addition_objs::colormap::Colormap;
use crate::plots::*;
use numpy::Element;
pub enum PlotData<'py, T: pyo3::conversion::ToPyObject + Element> {
// https://matplotlib.org/3.2.2/api/axes_api... | code_fim | hard | {
"lang": "rust",
"repo": "PhilDK1/rustmplotlib",
"path": "/src/figax/plots.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lamarmarshall/rust_test path: /loop-tag.rs
fn main(){
let mut x : u32 = 10;
let mut sec = false;
loop {
print!("good");
x -= 1;
if x < 0 {
if sec {
b<|fim_suffix|>= 1;
if x > 10 {
sec = true;
break 'l1;
}
}
}
}<|fim_middle|>reak;
}
break 'l2;
}
loop {
p... | code_fim | medium | {
"lang": "rust",
"repo": "lamarmarshall/rust_test",
"path": "/loop-tag.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>= 1;
if x > 10 {
sec = true;
break 'l1;
}
}
}
}<|fim_prefix|>// repo: lamarmarshall/rust_test path: /loop-tag.rs
fn main(){
let mut x : u32 = 10;
let mut sec = false;
loop<|fim_middle|> {
print!("good");
x -= 1;
if x < 0 {
if sec {
break;
}
break 'l2;
}
loop {
p... | code_fim | medium | {
"lang": "rust",
"repo": "lamarmarshall/rust_test",
"path": "/loop-tag.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ear: i64) -> bool {
match (year % 4, year % 100, year % 400) {
(0, 0, 0) => true,
(0, 0, _) => false,
(0, _, _) => true,
(_, _, _) => false
}
}<|fim_prefix|>// repo: pradeepchhetri/fun path: /rustlang/practice/leap.rs
/// on every year that is evenly divisible by 4... | code_fim | medium | {
"lang": "rust",
"repo": "pradeepchhetri/fun",
"path": "/rustlang/practice/leap.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pradeepchhetri/fun path: /rustlang/practice/leap.rs
/// on every year that is evenly divisible by 4
/// except every year that is evenly divisible by 100
/// unless the year is also evenly divisible by 400
pub fn is_leap_year(y<|fim_suffix|>e,
(0, 0, _) => false,
(0, _, _)... | code_fim | medium | {
"lang": "rust",
"repo": "pradeepchhetri/fun",
"path": "/rustlang/practice/leap.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> while accumulator.as_secs_f64() > fps_delta {
accumulator = accumulator.saturating_sub(Duration::from_secs_f64(fps_delta));
// Process all the gamepad events
while gilrs.next_event().is_some() {}
... | code_fim | hard | {
"lang": "rust",
"repo": "Gigoteur/UnicornConsole",
"path": "/unicorn-console/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if out_y > 0.0 {
mouse_events.wheel_down = true
} else if out_y < 0.0 {
mouse_events.wheel_up = true
}
if out_x > 0.0 {
mouse_events.wheel_right = true
... | code_fim | hard | {
"lang": "rust",
"repo": "Gigoteur/UnicornConsole",
"path": "/unicorn-console/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Gigoteur/UnicornConsole path: /unicorn-console/src/main.rs
mod gui;
mod input;
mod fps;
mod frametimes;
mod network;
use network::UnicornConsoleState;
use network::SessionDescriptor;
use unicorn;
use crate::input::{LocalInputManager, MouseEventCollector, LocalPlayerId};
use crate::{
gui:... | code_fim | hard | {
"lang": "rust",
"repo": "Gigoteur/UnicornConsole",
"path": "/unicorn-console/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fossabot/multi-seq-align path: /src/lib.rs
ions() {
println!("{:?}", aas);
assert_eq!(aas.len(), 4); // 4 sequences
}
# Ok(())
# }
```
Here I instancied an alignment using `u8`, but `Alignment` works on generics like numbers, custom or third-party structs.
# Features
- Create [`Align... | code_fim | hard | {
"lang": "rust",
"repo": "fossabot/multi-seq-align",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fossabot/multi-seq-align path: /src/lib.rs
uct.Alignment.html#method.iter_sequences
[`add()`]: struct.Alignment.html#method.add
[`with_sequences()`]: struct.Alignment.html#method.with_sequences
*/
#![warn(clippy::all, clippy::pedantic, clippy::nursery, clippy::cargo)]
mod errors;
mod utils;
us... | code_fim | hard | {
"lang": "rust",
"repo": "fossabot/multi-seq-align",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let align =
Alignment::with_sequences(&[b"ALKHITAN".to_vec(), b"VLK-ITAN".to_vec()]).unwrap();
assert_eq!(align.nth_position(3).unwrap(), vec![&b'H', &b'-'])
}
#[test]
fn nth_residues_more_seqs() {
let align = Alignment::with_sequences(&[
b"ALKH... | code_fim | hard | {
"lang": "rust",
"repo": "fossabot/multi-seq-align",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MysticDoll/wasmdump path: /src/converter/vectors.rs
use crate::converter::Converter;
use std::io::Read;
impl<T, S> Converter<Vec<T>> for S
where
S: Converter<T> + Read,
{
fn convert(&mut self) -> Result<Vec<T>, String> {
let num = leb128::read::unsigned(self)
.map_er... | code_fim | hard | {
"lang": "rust",
"repo": "MysticDoll/wasmdump",
"path": "/src/converter/vectors.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn convert_collectly_vec_functype() -> Result<(), String> {
let src = vec![
0x02u8, // num functypes
0x60u8, 0x02u8, 0x7fu8, 0x7fu8, 0x01u8, 0x7eu8, // functype 0
0x60u8, 0x02u8, 0x7du8, 0x7du8, 0x01u8, 0x7cu8, // functype 1
];
le... | code_fim | hard | {
"lang": "rust",
"repo": "MysticDoll/wasmdump",
"path": "/src/converter/vectors.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>async fn launch_panopto_and_get_stream_specs(
api: &Api,
context_id: &str,
resource_link_id: &str,
) -> Result<Vec<StreamSpec>> {
let response = panopto::launch(
api,
&format!(
"lti/Launch/panopto?context_id={}&resource_link_id={}",
context_id, resou... | code_fim | hard | {
"lang": "rust",
"repo": "btzy/fluminurs",
"path": "/src/weblecture.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn last_updated(&self) -> SystemTime {
self.last_updated
}
async fn download(
&self,
api: &Api,
destination: &Path,
temp_destination: &Path,
overwrite: OverwriteMode,
) -> Result<OverwriteResult> {
let context_id: &str = &self.module... | code_fim | hard | {
"lang": "rust",
"repo": "btzy/fluminurs",
"path": "/src/weblecture.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: btzy/fluminurs path: /src/weblecture.rs
use std::path::{Path, PathBuf};
use std::time::SystemTime;
use async_trait::async_trait;
use reqwest::Method;
use serde::Deserialize;
use crate::panopto;
use crate::resource;
use crate::resource::{OverwriteMode, OverwriteResult, Resource};
use crate::str... | code_fim | hard | {
"lang": "rust",
"repo": "btzy/fluminurs",
"path": "/src/weblecture.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ampcpmgp/weekly-report path: /rust-study/programming/src/enum_case.rs
// https://doc.rust-lang.org/book/ch06-01-defining-an-enum.html
use std::net::Ipv6Addr;
#[derive(Debug)]
enum Message {
Quit,
Move { x: i32, y: i32 },
Write(String),
<|fim_suffix|> // Option<T> 型はpreludeで読まれ... | code_fim | hard | {
"lang": "rust",
"repo": "ampcpmgp/weekly-report",
"path": "/rust-study/programming/src/enum_case.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // 標準ライブラリにもある
let std_ip = std::net::IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1));
println!("{:?}", home);
println!("{:?}", loopback);
println!("{}", std_ip);
// Option<T> 型はpreludeで読まれる
let some_number = Some(5);
let some_string = Some("a string");
let absent_n... | code_fim | hard | {
"lang": "rust",
"repo": "ampcpmgp/weekly-report",
"path": "/rust-study/programming/src/enum_case.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if absent_number == None {
println!("absent_number none");
}
println!("{:?}", Message::Quit);
println!("{:?}", Message::Move { x: 1, y: 2 });
println!("{:?}", Message::Write(String::from("hello")));
println!("{:?}", Message::ChangeColor(0, 0, 0));
Message::call();
}<|f... | code_fim | hard | {
"lang": "rust",
"repo": "ampcpmgp/weekly-report",
"path": "/rust-study/programming/src/enum_case.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zaeleus/noodles path: /noodles-gff/src/record/attributes/field.rs
//! GFF record attributes field.
pub mod tag;
pub mod value;
pub use self::{tag::Tag, value::Value};
use std::{
borrow::Cow,
error,
fmt::{self, Display},
str,
};
use percent_encoding::{percent_decode_str, utf8_... | code_fim | hard | {
"lang": "rust",
"repo": "zaeleus/noodles",
"path": "/noodles-gff/src/record/attributes/field.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok((key, value))
}
pub(super) fn percent_decode(s: &str) -> Result<Cow<'_, str>, str::Utf8Error> {
percent_decode_str(s).decode_utf8()
}
pub(super) fn percent_encode(s: &str) -> Cow<'_, str> {
utf8_percent_encode(s, PERCENT_ENCODE_SET).into()
}
#[cfg(test)]
mod tests {
use super::*;
... | code_fim | hard | {
"lang": "rust",
"repo": "zaeleus/noodles",
"path": "/noodles-gff/src/record/attributes/field.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub(super) fn parse_field(s: &str) -> Result<(Tag, Value), ParseError> {
let (raw_key, raw_value) = s.split_once(SEPARATOR).ok_or(ParseError::Invalid)?;
let key: Tag = percent_decode(raw_key)
.map(|k| k.into())
.map_err(ParseError::InvalidKey)?;
let value = raw_value
... | code_fim | hard | {
"lang": "rust",
"repo": "zaeleus/noodles",
"path": "/noodles-gff/src/record/attributes/field.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jkarns275/rust-tftp path: /src/send.rs
use std::net::{ SocketAddr, ToSocketAddrs };
use bit_set::BitSet;
use bit_vec::BitVec;
use std::fs::File;
use std::io::{ self, Seek };
use futures::{ Future, Poll, Async };
use std::net::UdpSocket;
use std::time::Duration;
use std::sync::{ Arc, Mutex };
use... | code_fim | hard | {
"lang": "rust",
"repo": "jkarns275/rust-tftp",
"path": "/src/send.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn receive_header(&mut self) -> Result<Option<Header>, io::Error> {
if let Ok(ref mut socket) = self.socket.clone().try_lock() {
socket.set_read_timeout(None)?;
match Header::recv(self.host_addr.clone(), socket) {
Ok(r) => { self.err_counter = 0; Ok(Som... | code_fim | hard | {
"lang": "rust",
"repo": "jkarns275/rust-tftp",
"path": "/src/send.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cassandraoconnell/rustdown path: /src/document/preliminaries/character.rs
use super::{LeftoverString, MatchedString, Matcher, RejectedString};
pub struct Character;
<|fim_suffix|> let character = Character;
assert_eq!(
character.try_match(String::from("ab")),
... | code_fim | hard | {
"lang": "rust",
"repo": "cassandraoconnell/rustdown",
"path": "/src/document/preliminaries/character.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let character = Character;
assert_eq!(
character.try_match(String::from("ab")),
Ok((String::from("a"), String::from("b")))
);
}
#[test]
fn it_rejects_empty_string() {
let character = Character;
assert_eq!(character.try_match(St... | code_fim | medium | {
"lang": "rust",
"repo": "cassandraoconnell/rustdown",
"path": "/src/document/preliminaries/character.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Got result {} with duration {:?} from {}", result, duration, fnname);
}
}<|fim_prefix|>// repo: szbergeron/fizzbuzz_opt path: /src/main.rs
use std::time::{Duration, Instant};
pub mod lib;
use lib::*;
<|fim_middle|>fn main() {
let upper = 1000000000;
for (f, fnname) in [
... | code_fim | hard | {
"lang": "rust",
"repo": "szbergeron/fizzbuzz_opt",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: szbergeron/fizzbuzz_opt path: /src/main.rs
use std::time::{Duration, Instant};
pub mod lib;
use lib::*;
<|fim_suffix|> for (f, fnname) in [
(nothing as fn(u64) -> u64, "empty"),
(fnaive1, "fnaive1"),
(fopt1, "fopt1"),
(fopt2, "fopt2"),
(fopt3, "fopt3... | code_fim | medium | {
"lang": "rust",
"repo": "szbergeron/fizzbuzz_opt",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (f, fnname) in [
(nothing as fn(u64) -> u64, "empty"),
(fnaive1, "fnaive1"),
(fopt1, "fopt1"),
(fopt2, "fopt2"),
(fopt3, "fopt3"),
(fzbz2, "fzbz2"),
(fzbz1, "fzbz1"),
(fbf, "fbf"),
].iter() {
//let f: &fn(u64) -> u64 = f;
... | code_fim | medium | {
"lang": "rust",
"repo": "szbergeron/fizzbuzz_opt",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn print_dimacs(&self, writer: &mut impl io::Write) -> io::Result<()> {
writeln!(writer, "p cnf {} {}", self.active_variables, self.clauses.len())?;
for clause in self.clauses.iter() {
for lit in clause.iter() {
if lit.negated() {
write!(writer, "-")?;
}
write!(writer, "{} ", ... | code_fim | hard | {
"lang": "rust",
"repo": "danielschemmel/drsat",
"path": "/src/cnf/problem/print.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: danielschemmel/drsat path: /src/cnf/problem/print.rs
use std::{fmt, io, str};
use super::Problem;
impl<T: fmt::Display> Problem<T> {
pub fn print(&self, writer: &mut impl io::Write) -> io::Result<()> {
writeln!(writer, "Problem of {} clauses:", self.clauses.len())?;
for clause in &self.cl... | code_fim | hard | {
"lang": "rust",
"repo": "danielschemmel/drsat",
"path": "/src/cnf/problem/print.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jcomito/rmkts path: /src/data.rs
extern crate serde_json;
use serde_json::Value;
const BASE_URL: &str = "https://query1.finance.yahoo.com/v7/finance/quote?symbols=";
struct StockData {
ticker: String,
last_price: f64,
open: f64,
high: f64,
low: f64,
close: f64,
cha... | code_fim | hard | {
"lang": "rust",
"repo": "jcomito/rmkts",
"path": "/src/data.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> StockDataDisplay {
ticker: self.ticker.clone(),
last_price: money_format(self.last_price),
open: money_format(self.open),
high: money_format(self.high),
low: money_format(self.low),
close: money_format(self.close),
... | code_fim | hard | {
"lang": "rust",
"repo": "jcomito/rmkts",
"path": "/src/data.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn extract_stock_data(r: &Value) -> Result<StockData, &'static str> {
let s = StockData::new(r["symbol"].as_str().unwrap_or(""),
r["regularMarketPrice"].as_f64().unwrap_or(0.0),
r["regularMarketOpen"].as_f64().unwrap_or(0.0),
... | code_fim | hard | {
"lang": "rust",
"repo": "jcomito/rmkts",
"path": "/src/data.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for _ in 0..pred_size {
readable.read_exact(&mut buffer)?;
let y = f32::from_le_bytes(buffer);
readable.read_exact(&mut buffer)?;
let x = f32::from_le_bytes(buffer);
predictions.push(Vecto... | code_fim | hard | {
"lang": "rust",
"repo": "merzlikina/pico-detect",
"path": "/src/localizer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: merzlikina/pico-detect path: /src/localizer.rs
use std::io::{Error, ErrorKind, Read};
use image::GrayImage;
use na::geometry::{Similarity2, Translation2, UnitComplex};
use na::{Point2, Point3, Vector2, Vector3};
use rand::distributions::Uniform;
use rand::{Rng, RngCore};
use super::core::{Bin... | code_fim | hard | {
"lang": "rust",
"repo": "merzlikina/pico-detect",
"path": "/src/localizer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> readable.read_exact(&mut buffer)?;
let x = f32::from_le_bytes(buffer);
predictions.push(Vector2::new(x, y));
}
stage.push((tree, predictions));
}
stages.push(stage);
}
Ok... | code_fim | hard | {
"lang": "rust",
"repo": "merzlikina/pico-detect",
"path": "/src/localizer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn distance_fifths() {
let cases: &[(Key, Key, i8)] = &[
(C, C, 0),
(C, G, 1),
(C, D, 2),
(C, A, 3),
(C, E, 4),
(C, B, 5),
(C, Gb, 6),
(C, Db, -5),
(C, Ab, -4)... | code_fim | hard | {
"lang": "rust",
"repo": "vitobasso/rust-synth",
"path": "/src/core/music_theory/diatonic_scale.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vitobasso/rust-synth path: /src/core/music_theory/diatonic_scale.rs
use std::ops::{Add, Sub};
use super::{num_traits::FromPrimitive, Octave, pitch::Pitch, pitch_class::PitchClass::{self, *}};
use self::ScaleDegree::*;
#[derive(Clone, Copy, PartialEq, Eq, Debug, FromPrimitive)]
pub enum ScaleDeg... | code_fim | hard | {
"lang": "rust",
"repo": "vitobasso/rust-synth",
"path": "/src/core/music_theory/diatonic_scale.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn make_error_response(error_message: &str) -> FutureResult<hyper::Response, hyper::Error> {
let payload = json!({"error": error_message}).to_string();
let response = Response::new()
.with_status(StatusCode::InternalServerError)
.with_header(ContentLength(payload.len() as u64))
... | code_fim | hard | {
"lang": "rust",
"repo": "VentGrey/rust-microservice",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: VentGrey/rust-microservice path: /src/main.rs
#[macro_use]
extern crate log;
extern crate env_logger;
#[macro_use]
extern crate serde_json;
use hyper::header::ContentLength;
use std::error::Error;
use futures::stream::Stream;
use futures::future::FutureResult;
use hyper::Chunk;
use hyper::serv... | code_fim | hard | {
"lang": "rust",
"repo": "VentGrey/rust-microservice",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: duchu89/design_patterns path: /abstract_factory/src/progress_bar.rs
pub trait ProgressBar {
fn draw(&self);
}
<|fim_suffix|> println!("Drawing Cupertino style Progress Bar");
}
}<|fim_middle|>pub struct MaterialProgressBar;
impl ProgressBar for MaterialProgressBar {
fn draw(... | code_fim | hard | {
"lang": "rust",
"repo": "duchu89/design_patterns",
"path": "/abstract_factory/src/progress_bar.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Drawing Material style Progress Bar");
}
}
pub struct CupertinoProgressBar;
impl ProgressBar for CupertinoProgressBar {
fn draw(&self) {
println!("Drawing Cupertino style Progress Bar");
}
}<|fim_prefix|>// repo: duchu89/design_patterns path: /abstract_factory/src/... | code_fim | medium | {
"lang": "rust",
"repo": "duchu89/design_patterns",
"path": "/abstract_factory/src/progress_bar.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[allow(unused_macros)]
macro_rules! pchar {
($name:expr) => {
CString::new($name).unwrap().as_ptr()
};
}
macro_rules! boolclosure {
($b:block) => {
|| -> Option<()> { $b }().is_some()
};
}<|fim_prefix|>// repo: CyberSys/core-1 path: /src/common_ffi.rs
use libc::c_char;
u... | code_fim | medium | {
"lang": "rust",
"repo": "CyberSys/core-1",
"path": "/src/common_ffi.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CyberSys/core-1 path: /src/common_ffi.rs
use libc::c_char;
use std::ffi::{CStr, CString};
pub type PChar = *const c_char;
pub fn pchar_to_string<'a>(s: PChar) -> Option<String> {
if s.is_null() {
None
} else {
unsafe { Some(String::from(CStr::from_ptr(s).to_string_lossy... | code_fim | hard | {
"lang": "rust",
"repo": "CyberSys/core-1",
"path": "/src/common_ffi.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: osolmaz/profiling_precision_poc path: /benches/criterion_test1.rs
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use profiling_precision_poc::empty;
use profiling_precision_poc::fibonacci;
use profiling_precision_poc::generate_random_u64;
use profiling_precision_poc::inc... | code_fim | medium | {
"lang": "rust",
"repo": "osolmaz/profiling_precision_poc",
"path": "/benches/criterion_test1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> c.bench_function("increment_u128", |b| b.iter(|| increment_u128(&mut a)));
c.bench_function("fibonacci 20", |b| b.iter(|| fibonacci(black_box(20))));
c.bench_function("generate_random_u64", |b| {
b.iter(|| generate_random_u64(&mut rng))
});
c.bench_function("empty", |b| b.iter(... | code_fim | medium | {
"lang": "rust",
"repo": "osolmaz/profiling_precision_poc",
"path": "/benches/criterion_test1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn hash_string(msg: &str) -> String {
let mut hasher = Sha256::new();
hasher.input_str(msg);
hasher.result_str()
}
pub fn generate_uuid() -> String {
Uuid::new_v4().to_string()
}
pub fn check_key(key: &str, hashed_key: &str) -> bool {
let ... | code_fim | medium | {
"lang": "rust",
"repo": "MathiasPius/rublic",
"path": "/src/cryptoutil.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn generate_uuid() -> String {
Uuid::new_v4().to_string()
}
pub fn check_key(key: &str, hashed_key: &str) -> bool {
let salted_key = format!("Rublic Salt Goes Here {}", key);
pbkdf2_check(&salted_key, hashed_key).unwrap_or(false)
}
}<|fim_prefix|>// repo: Mathi... | code_fim | hard | {
"lang": "rust",
"repo": "MathiasPius/rublic",
"path": "/src/cryptoutil.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MathiasPius/rublic path: /src/cryptoutil.rs
use rand::{Rng};
use uuid::Uuid;
use crypto::{
pbkdf2::{pbkdf2_check, pbkdf2_simple},
sha2::Sha256,
digest::Digest
};
pub struct CryptoUtil {}
impl CryptoUtil {
pub fn generate_key() -> String {
rand::thread_rng()
... | code_fim | medium | {
"lang": "rust",
"repo": "MathiasPius/rublic",
"path": "/src/cryptoutil.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bfjelds/onvif-rs path: /examples/camera_datetime.rs
extern crate onvif_rs;
use onvif_rs::{schema, soap};
#[tokio::main]
async fn main() {
let uri = match std::env::args().skip(1).next() {
<|fim_suffix|>ap_or("camera_datetime".into())
);
std::process::exit(1);
... | code_fim | medium | {
"lang": "rust",
"repo": "bfjelds/onvif-rs",
"path": "/examples/camera_datetime.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ap_or("camera_datetime".into())
);
std::process::exit(1);
}
};
let mut client = soap::client::Client::new(&uri, None);
let date = schema::devicemgmt::get_system_date_and_time(&mut client, &Default::default()).await;
println!("{:#?}", date);
}<|fim_prefix|>... | code_fim | medium | {
"lang": "rust",
"repo": "bfjelds/onvif-rs",
"path": "/examples/camera_datetime.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let avatar = Avatar::new(hash, false).unwrap();
let image_buffer = avatar.draw(128, quadrant, true, false, false, false, false);
let image = DynamicImage::ImageRgba8(image_buffer);
image.save("out.png").unwrap();
}<|fim_prefix|>// repo: drbrain/unicornify.rs path: /src/bin/unicornify.rs
... | code_fim | hard | {
"lang": "rust",
"repo": "drbrain/unicornify.rs",
"path": "/src/bin/unicornify.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: drbrain/unicornify.rs path: /src/bin/unicornify.rs
use image::DynamicImage;
use std::env::args;
use unicornify::Avatar;
<|fim_suffix|> let hash = match args().nth(1) {
Some(h) => h,
None => String::from("58479f76374a3ba3c69b9804163f39f4"),
};
let quadrant = match ar... | code_fim | medium | {
"lang": "rust",
"repo": "drbrain/unicornify.rs",
"path": "/src/bin/unicornify.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Logicalshift/flowbetween path: /animation/src/serializer/edit/animation_edit.rs
use super::super::source::*;
use super::super::target::*;
use crate::traits::*;
use std::str::{Chars};
use std::time::{Duration};
impl AnimationEdit {
///
/// Returns true if this edit should be written to ... | code_fim | hard | {
"lang": "rust",
"repo": "Logicalshift/flowbetween",
"path": "/animation/src/serializer/edit/animation_edit.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(AnimationEdit::deserialize(&mut encoded.chars()) == Some(AnimationEdit::SetFrameLength(Duration::from_nanos(1_000_000_000 / 24))));
}
#[test]
fn set_length() {
let mut encoded = String::new();
AnimationEdit::SetLength(Duration::from_secs(80)).serialize(&mut enc... | code_fim | hard | {
"lang": "rust",
"repo": "Logicalshift/flowbetween",
"path": "/animation/src/serializer/edit/animation_edit.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> while let Some((key, value)) = eat_if_matches!(parser,
Record::BranchData { line, block, branch, taken } => {
(Key { line, block, branch }, Value { taken })
}
) {
let _ = branches.insert(key, value);
}
let _ = eat_if_matches!(parser, Record::BranchesFou... | code_fim | hard | {
"lang": "rust",
"repo": "PSeitz/lcov",
"path": "/lcov/src/report/section/branch.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PSeitz/lcov path: /lcov/src/report/section/branch.rs
//! A coverage information about a branch.
//!
//! Some coverage information is stored in a [`Branches`] as `BTreeMap` .
//!
//! [`Branches`]: ./type.Branches.html
use super::{Merge, MergeError, ParseError, Parser, ReadError, Record};
use std:... | code_fim | hard | {
"lang": "rust",
"repo": "PSeitz/lcov",
"path": "/lcov/src/report/section/branch.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: junosuarez/aoc2019 path: /day02/src/main.rs
fn main() {
let mut memory: Vec<i32> = vec![];
// Find the input noun and verb that cause the program to produce the output 19690720.
'outer: for noun in 0..100 {
for verb in 0..100 {
memory = parse("1,0,0,3,1,1,2,3,1,3,4,3,1,5,0,3,2,6... | code_fim | hard | {
"lang": "rust",
"repo": "junosuarez/aoc2019",
"path": "/day02/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn render(memory: &Vec<i32>) -> String {
return memory
.iter()
.map(|s| s.to_string())
.collect::<Vec<String>>()
.join(",");
}
fn calculate(mut memory: Vec<i32>) -> Vec<i32> {
let mut instruction_pointer = 0;
loop {
let opcode = memory[instruction_pointer];
if opcode == 99 ... | code_fim | hard | {
"lang": "rust",
"repo": "junosuarez/aoc2019",
"path": "/day02/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut memory: Vec<i32> = expr
.split(",")
.map(|s| s.parse::<i32>().expect("x"))
.collect();
let mut instruction_pointer = 0;
loop {
let opcode = memory[instruction_pointer];
if opcode == 99 {
// halt immediately
break;
}
let left_op = memory[instruction_p... | code_fim | hard | {
"lang": "rust",
"repo": "junosuarez/aoc2019",
"path": "/day02/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> async fn apply_script(&self, script: &str) -> ConnectorResult<()> {
Ok(self.conn().raw_cmd(script).await?)
}
}
impl SqlMigrationConnector {
async fn apply_next_step(
&self,
steps: &[SqlMigrationStep],
index: usize,
renderer: &(dyn SqlFlavour + Send + Sy... | code_fim | hard | {
"lang": "rust",
"repo": "2color/prisma-engines",
"path": "/migration-engine/connectors/sql-migration-connector/src/sql_database_step_applier.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl SqlMigrationConnector {
async fn apply_next_step(
&self,
steps: &[SqlMigrationStep],
index: usize,
renderer: &(dyn SqlFlavour + Send + Sync),
schemas: Pair<&SqlSchema>,
) -> ConnectorResult<bool> {
let has_this_one = steps.get(index).is_some();
... | code_fim | hard | {
"lang": "rust",
"repo": "2color/prisma-engines",
"path": "/migration-engine/connectors/sql-migration-connector/src/sql_database_step_applier.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 2color/prisma-engines path: /migration-engine/connectors/sql-migration-connector/src/sql_database_step_applier.rs
use crate::{
pair::Pair,
sql_migration::{CreateTable, DropTable, SqlMigration, SqlMigrationStep},
SqlFlavour, SqlMigrationConnector,
};
use migration_connector::{
Con... | code_fim | hard | {
"lang": "rust",
"repo": "2color/prisma-engines",
"path": "/migration-engine/connectors/sql-migration-connector/src/sql_database_step_applier.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vple/aoc2019 path: /src/day1.rs
use std::cmp::max;
#[aoc_generator(day1)]
fn parse(input: &str) -> Vec<i32> {
input.lines().filter_map(|l| l.parse().ok()).collect()
}
#[aoc(day1, part1)]
fn part1(masses: &[i32]) -> i32 {
masses.iter().map(|m| required_fuel(*m)).sum()
}
<|fim_suffix|>f... | code_fim | medium | {
"lang": "rust",
"repo": "vple/aoc2019",
"path": "/src/day1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> max(mass / 3 - 2, 0)
}
fn recursive_required_fuel(mass: i32) -> i32 {
let fuel = required_fuel(mass);
match fuel {
0 => 0,
_ => fuel + recursive_required_fuel(fuel),
}
}<|fim_prefix|>// repo: vple/aoc2019 path: /src/day1.rs
use std::cmp::max;
#[aoc_generator(day1)]
fn pa... | code_fim | medium | {
"lang": "rust",
"repo": "vple/aoc2019",
"path": "/src/day1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let fuel = required_fuel(mass);
match fuel {
0 => 0,
_ => fuel + recursive_required_fuel(fuel),
}
}<|fim_prefix|>// repo: vple/aoc2019 path: /src/day1.rs
use std::cmp::max;
#[aoc_generator(day1)]
fn parse(input: &str) -> Vec<i32> {
input.lines().filter_map(|l| l.parse().o... | code_fim | hard | {
"lang": "rust",
"repo": "vple/aoc2019",
"path": "/src/day1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sorphin/dni-header-util path: /src/dni_header.rs
use std::io;
use std::io::prelude::*;
pub const DNI_HDR_LEN: usize = 128usize;
pub type Header = Vec<(String, String)>;
pub fn read<T>(input: &mut T) -> io::Result<Header>
where
T: Read,
{
let buf = &mut [0u8; DNI_HDR_LEN];
let _rea... | code_fim | hard | {
"lang": "rust",
"repo": "sorphin/dni-header-util",
"path": "/src/dni_header.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn insert(header: &mut Header, key: String, value: String) {
let pos = header.iter().position(|(k, _v)| k == &key);
match pos {
Some(pos) => header[pos] = (key, value),
None => header.push((key, value)),
}
}
#[allow(clippy::ptr_arg)]
pub fn write<T>(output: &mut T, header:... | code_fim | hard | {
"lang": "rust",
"repo": "sorphin/dni-header-util",
"path": "/src/dni_header.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn lines(&self) -> LineIter;
fn iter_line(&self, line: usize) -> CharIter;
fn line_index_to_char_index(&self, line: usize) -> usize;
}
pub type CharIter<'a> = ropey::iter::Chars<'a>;
pub type LineIter<'a> = ropey::iter::Lines<'a>;
pub trait Named {
fn name(&self) -> &String;
fn set_n... | code_fim | medium | {
"lang": "rust",
"repo": "redox-os/Smith",
"path": "/src/state/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: redox-os/Smith path: /src/state/mod.rs
mod text;
mod record;
mod select;
pub use self::text::Text;
pub use self::record::Recorded;
pub use self::record::Undoable;
pub use self::select::{Select, Selectable};
use std::io::Result;
use ropey;
pub trait Editable {
fn step(&mut self, mov: Movem... | code_fim | medium | {
"lang": "rust",
"repo": "redox-os/Smith",
"path": "/src/state/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> register = *cell;
*cell = Wrapping(0u8);
},
IR::Scan(val, step) => loop {
if *cell!(read, tape, index) == *val {
break;
}
index += *step;
},
IR::Fill(off, ... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/rbf",
"path": "/src/evaluator.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/rbf path: /src/evaluator.rs
use std::io::{Read, Write, Error};
use std::cmp::max;
use std::num::Wrapping;
use std::collections::VecDeque;
use std::iter::repeat;
use crate::internal::*;
#[inline]
fn touch_range(
tape : &mut VecDeque<Wrapping<u8>>,
index : &mut isize,
high : ... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/rbf",
"path": "/src/evaluator.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for inst in prog.iter() {
match inst {
IR::Touch(high, low) => {
touch_range(tape, &mut index, *high, *low);
},
IR::Set(off, val) => {
*cell!(write, tape, index + off) = *val;
},
IR::Add(off, val) => ... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/rbf",
"path": "/src/evaluator.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> check_expected_results(PastOperations, source, expected1);
let expected2 = r"/* {Init, Rotation, Translation} */ init(50, 50, 50, 50);
/* {Rotation, Translation} */ translation(10, 0);
iter {
/* {Rotation, Translation} */ translation(10, 0);
/* {Rotation, Translation} */ rotation(0, 0, 90)
}"... | code_fim | hard | {
"lang": "rust",
"repo": "Xazax-hun/domains-oxide",
"path": "/transform-lib/src/analysis/reachability_analysis_tests.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Xazax-hun/domains-oxide path: /transform-lib/src/analysis/reachability_analysis_tests.rs
use crate::{
analysis::reachability_analysis::FutureOperations,
analysis::reachability_analysis::PastOperations, analysis::test_utils::check_expected_results,
};
#[test]
fn test_primitive_program() ... | code_fim | hard | {
"lang": "rust",
"repo": "Xazax-hun/domains-oxide",
"path": "/transform-lib/src/analysis/reachability_analysis_tests.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut runtime = metatape::runtime_from_file(&filename).unwrap_or_else(|error_msg| {
println!("{}", error_msg);
std::process::exit(1);
});
if verbose {
runtime.set_output_fn(Box::new(|byte| {
println!("Output byte {:#02x}: {:#?}", byte, byte as char);
... | code_fim | medium | {
"lang": "rust",
"repo": "HactarCE/Metatape",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: HactarCE/Metatape path: /src/main.rs
#[macro_use]
extern crate pest_derive;
mod cli;
mod metatape;
fn main() {
let config = cli::get_config().unwrap_or_else(|_| {
cli::print_usage();
std::process::exit(0);
});
<|fim_suffix|> let mut runtime = metatape::runtime_from_... | code_fim | medium | {
"lang": "rust",
"repo": "HactarCE/Metatape",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut result = Ok(());
while result.is_ok() {
if verbose {
result = runtime.debug_step()
} else {
result = runtime.step().map(|_| ());
}
if let Err(metatape::RuntimeError::Halt) = result {
println!("HALT");
result = ... | code_fim | hard | {
"lang": "rust",
"repo": "HactarCE/Metatape",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oniproject/oni path: /src/incoming.rs
use std::{
net::SocketAddr,
collections::HashMap,
sync::atomic::{AtomicU64, Ordering},
time::Duration,
};
use crate::{
token::{
ChallengeToken,
PrivateToken,
CHALLENGE_LEN,
},
crypto::{keygen, KEY, HMAC},
... | code_fim | hard | {
"lang": "rust",
"repo": "oniproject/oni",
"path": "/src/incoming.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn gen_challenge(&self, seq: u64, buf: &mut [u8], token: &PrivateToken) -> usize {
let challenge_seq = self.sequence.fetch_add(1, Ordering::Relaxed);
let mut m = ChallengeToken::new(token.client_id(), *token.user())
.encode_packet(challenge_seq, &self.key);
Pack... | code_fim | hard | {
"lang": "rust",
"repo": "oniproject/oni",
"path": "/src/incoming.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn remove(&mut self, addr: &SocketAddr) -> Option<KeyPair> {
self.pending.remove(addr)
}
pub fn insert(&mut self, addr: SocketAddr, expire: u64, token: &PrivateToken) {
self.pending.entry(addr).or_insert_with(|| KeyPair::new(expire, &token));
}
pub fn add_token_hist... | code_fim | hard | {
"lang": "rust",
"repo": "oniproject/oni",
"path": "/src/incoming.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gunsafighter/windows-rs path: /tests/handles/tests/null.rs
use test_handles::{
Windows::Win32::Graphics::Gdi::HGDIOBJ,
Windows::Win32::System::SystemServices::{HANDLE, PSTR, PWSTR},
};
#[test]
fn test() {
assert_eq!(HANDLE::NULL, HANDLE(0));
assert_eq!(HANDLE::NULL.is_null(), tr... | code_fim | medium | {
"lang": "rust",
"repo": "gunsafighter/windows-rs",
"path": "/tests/handles/tests/null.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(PSTR::NULL, PSTR(std::ptr::null_mut()));
assert_eq!(PSTR::NULL.is_null(), true);
assert_eq!(PWSTR::NULL, PWSTR(std::ptr::null_mut()));
assert_eq!(PWSTR::NULL.is_null(), true);
assert_eq!(HGDIOBJ::NULL, HGDIOBJ(0));
assert_eq!(HGDIOBJ::NULL.is_null(), true);
assert_... | code_fim | medium | {
"lang": "rust",
"repo": "gunsafighter/windows-rs",
"path": "/tests/handles/tests/null.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: notkilometers/Data-Structures path: /new-singly-linked-list.rs
struct Node {
val: i32,
next: Option<Box<Node>>,
}
impl Node {
fn new(val: i32) -> Self {
<|fim_suffix|> match &mut self.next {
Some(n) => {
n.insert(val)
},
Non... | code_fim | hard | {
"lang": "rust",
"repo": "notkilometers/Data-Structures",
"path": "/new-singly-linked-list.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("{}", self.val);
match &self.next {
Some(n) => {
n.print();
},
None => {
println!("Reached end of linked list");
},
};
}
}<|fim_prefix|>// repo: notkilometers/Data-Structures path: /new-si... | code_fim | hard | {
"lang": "rust",
"repo": "notkilometers/Data-Structures",
"path": "/new-singly-linked-list.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn get_string(name: &str) -> String {
fs::read_to_string(format!("inputs/{}", name)).expect("Something went wrong reading the file")
}<|fim_prefix|>// repo: droogmic/advent2020 path: /src/lib.rs
#[macro_use]
extern crate lazy_static;
use std::format;
use std::fs;
pub mod day1;
pub mod day10;
pu... | code_fim | hard | {
"lang": "rust",
"repo": "droogmic/advent2020",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: droogmic/advent2020 path: /src/lib.rs
#[macro_use]
extern crate lazy_static;
use std::format;
use std::fs;
pub mod day1;
pub mod day10;
pub mod day11;
pub mod day12;
pub mod day13;
pub mod day14;
pub mod day15;
pub mod day16;
pub mod day17;
pub mod day2;
pub mod day3;
pub mod day4;
pub mod day... | code_fim | hard | {
"lang": "rust",
"repo": "droogmic/advent2020",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn get_days() -> Vec<fn() -> Day> {
vec
- [index node header](https://flatcap.org/linux-ntfs/ntfs/concepts/node_header.html)
- [index entry](https://flatc... | code_fim | hard | {
"lang": "rust",
"repo": "larntz/mft_muncher",
"path": "/src/ntfs_attributes/index_root.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match entry_flag {
0x3 | 0x1 => {
let sub_node_vcn = u64::from_le_bytes(
get_bytes_8(&entry[length_of_entry as usize - 8..]).unwrap(),
);
println!("sub node vcn {}", sub_node_vcn);
... | code_fim | hard | {
"lang": "rust",
"repo": "larntz/mft_muncher",
"path": "/src/ntfs_attributes/index_root.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn file_open(&mut self, cfg: &'static SuricataFileContext, track_id: &u32, name: &[u8], flags: u16) -> i32 {
0
}
pub fn file_append(&mut self, track_id: &u32, data: &[u8], is_gap: bool) -> i32 {
0
}
pub fn file_close(&mut self, track_id: &u32, flags: u16) -> i32 {... | code_fim | hard | {
"lang": "rust",
"repo": "epage/smb-rs",
"path": "/smb-parser/src/filecontainer.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn file_append(&mut self, track_id: &u32, data: &[u8], is_gap: bool) -> i32 {
0
}
pub fn file_close(&mut self, track_id: &u32, flags: u16) -> i32 {
0
}
pub fn files_prune(&mut self) {
}
pub fn file_set_txid_on_last_file(&mut self, tx_id: u64) {
}
}<|f... | code_fim | hard | {
"lang": "rust",
"repo": "epage/smb-rs",
"path": "/smb-parser/src/filecontainer.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: epage/smb-rs path: /smb-parser/src/filecontainer.rs
/* Copyright (C) 2017 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
* Software Foundation.
*
* This progra... | code_fim | medium | {
"lang": "rust",
"repo": "epage/smb-rs",
"path": "/smb-parser/src/filecontainer.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.