text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: andoriyu/material-design-icons-rs path: /src/materialiconsround/action/icon_rocket_launch.rs
pub struct IconRocketLaunch {
props: crate::Props,
}
impl yew::Component for IconRocketLaunch {
type Properties = crate::Props;
type Message = ();
fn create(props: Self::Properties, _: yew:... | code_fim | medium | {
"lang": "rust",
"repo": "andoriyu/material-design-icons-rs",
"path": "/src/materialiconsround/action/icon_rocket_launch.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: johnstonskj/rust-xml_dom_xpath path: /tests/spec_examples.rs
use xml_dom_xpath::xpath1::model::*;
macro_rules! select {
($axis:ident, $test:ident) => {
Predicate::select(AxisSpecifier::$axis, NodeTest::$test)
};
($axis:ident named $name:expr) => {
Predicate::select(A... | code_fim | hard | {
"lang": "rust",
"repo": "johnstonskj/rust-xml_dom_xpath",
"path": "/tests/spec_examples.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut path = LocationPath::absolute();
let mut step = Step::child_elements("para");
step.append(Predicate::eq(
select!(Attribute named "type"),
Predicate::literal("warning"),
));
path.append(step);
assert_eq!(
path.to_string(),
"/child::para[att... | code_fim | hard | {
"lang": "rust",
"repo": "johnstonskj/rust-xml_dom_xpath",
"path": "/tests/spec_examples.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut path = LocationPath::default();
let mut step = Step::child_elements("chapter");
step.append(select!(Child named "title"));
path.append(step);
assert_eq!(path.to_string(), "child::chapter[child::title]");
assert_eq!(path.to_abbr_string(), "chapter[title]");
}
#[test]
fn ... | code_fim | hard | {
"lang": "rust",
"repo": "johnstonskj/rust-xml_dom_xpath",
"path": "/tests/spec_examples.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn from_file(filename: &str) -> Option<Self> {
let image = imagefmt::read(filename, imagefmt::ColFmt::Auto);
match image {
Ok(image) => {
let (width, height) = (image.w, image.h);
let format = match image.fmt {
imagefm... | code_fim | hard | {
"lang": "rust",
"repo": "vitvakatu/genial.rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vitvakatu/genial.rs path: /src/lib.rs
extern crate imagefmt;
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct RGB {
data: [u8; 3],
}
pub fn rgb(r: u8, g: u8, b: u8) -> RGB {
RGB { data: [r, g, b] }
}
pub mod color {
use ::*;
pub const WHITE: RGB = RGB { data: [255, 255, 255... | code_fim | hard | {
"lang": "rust",
"repo": "vitvakatu/genial.rs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub trait Draw {
fn line(&mut self) -> LineBuilder;
fn circle(&mut self) -> CircleBuilder;
}
impl Draw for Image {
fn line(&mut self) -> LineBuilder {
LineBuilder {
image: self,
from: (0, 0),
to: (0, 0),
... | code_fim | hard | {
"lang": "rust",
"repo": "vitvakatu/genial.rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: erdos-project/erdos path: /erdos/src/node/operator_executors/two_in_one_out_executor.rs
Arc::get_mut(&mut self.operator).unwrap().run(
&self.config,
left_read_stream,
right_read_stream,
&mut self.write_stream,
);
}
fn exec... | code_fim | hard | {
"lang": "rust",
"repo": "erdos-project/erdos",
"path": "/erdos/src/node/operator_executors/two_in_one_out_executor.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: erdos-project/erdos path: /erdos/src/node/operator_executors/two_in_one_out_executor.rs
ite_stream.id()],
);
Arc::get_mut(&mut self.operator)
.unwrap()
.setup(&mut setup_context);
setup_context
}
fn execute_run(
&mut self,
... | code_fim | hard | {
"lang": "rust",
"repo": "erdos-project/erdos",
"path": "/erdos/src/node/operator_executors/two_in_one_out_executor.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JLockerman/FuzzyLog path: /examples/or_set/src/tester.rs
use std::sync::atomic::{AtomicBool, AtomicUsize};
use std::sync::atomic::Ordering::Relaxed;
use std::time::{Duration, Instant};
use or_set::OrSet;
use fuzzy_log_client::{
hash::{IdHashMap, IdSet},
fuzzy_log::log_handle::Uuid,
};... | code_fim | hard | {
"lang": "rust",
"repo": "JLockerman/FuzzyLog",
"path": "/examples/or_set/src/tester.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut start = Instant::now();
let experiment_start = start;
let (mut phase, mut num_pending) = (0, 0);
let mut i = 0;
let mut local_num_elapsed = 0;
while !quit.load(Relaxed) {
assert!(requests[i].start_time.is_none());
loop {
let now = Instant::now()... | code_fim | hard | {
"lang": "rust",
"repo": "JLockerman/FuzzyLog",
"path": "/examples/or_set/src/tester.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut res = Vec::with_capacity(username_bytes.len() + salt_bytes.len());
res.extend(salt_bytes);
res.extend(username_bytes);
Ok(res)
}
}<|fim_prefix|>// repo: technetos/heatshield path: /src/salt/get_salt.rs
use crate::{salt::SaltController, schema};
use diesel::pr... | code_fim | medium | {
"lang": "rust",
"repo": "technetos/heatshield",
"path": "/src/salt/get_salt.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: technetos/heatshield path: /src/salt/get_salt.rs
use crate::{salt::SaltController, schema};
use diesel::prelude::*;
use postgres_resource::ResourceController;
<|fim_suffix|> let mut res = Vec::with_capacity(username_bytes.len() + salt_bytes.len());
res.extend(salt_bytes);
... | code_fim | hard | {
"lang": "rust",
"repo": "technetos/heatshield",
"path": "/src/salt/get_salt.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/flate2/examples/gzdecoder-write.rs
extern
crate
flate2
;
use
flate2
:
:
write
:
:
{
GzDecoder
GzEncoder
}
;
use
flate2
:
:
Compression
;
use
std
:
:
io
;
use
std
:
:
io
:
:
prelude
:
:
*
;
/
/
Compress
a
sample
string
and
print
it
after
transfo... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/flate2/examples/gzdecoder-write.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
new
(
writer
)
;
decoder
.
write_all
(
&
bytes
[
.
.
]
)
?
;
decoder
.
try_finish
(
)
?
;
writer
=
decoder
.
finish
(
)
?
;
let
return_string
=
String
:
:
from_utf8
(
writer
)
.
expect
(
"
String
parsing
error
"
)
;
Ok
(
return_string
)
}<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_pa... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/flate2/examples/gzdecoder-write.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wujinderead/MyGoProjects path: /gotest/leet_rust/tests/leet2101_detonate_the_maximum_bombs.rs
// https://leetcode.com/problems/detonate-the-maximum-bombs/
// You are given a list of bombs. The range of a bomb is defined as the area where its effect
// can be felt. This area is in the shape of a... | code_fim | hard | {
"lang": "rust",
"repo": "wujinderead/MyGoProjects",
"path": "/gotest/leet_rust/tests/leet2101_detonate_the_maximum_bombs.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> *number += 1;
visited[i] = true;
for &n in &neighbor[i] {
if !visited[n] {
Solution::visit(n, neighbor, visited, number);
}
}
}
}
#[test]
fn test() {
let testcases = vec![
... | code_fim | hard | {
"lang": "rust",
"repo": "wujinderead/MyGoProjects",
"path": "/gotest/leet_rust/tests/leet2101_detonate_the_maximum_bombs.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let family_name = face.names()
.find(|name| name.name_id() == ttf_parser::name_id::FULL_NAME)
.and_then(|name| name.to_string());
let post_script_name = face.names()
.find(|name| name.name_id() == ttf_parser::name_id::POST_SCRIPT_NAME)
.and_then(|name| name.to_stri... | code_fim | medium | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/third_party/rust_crates/vendor/ttf-parser-0.10.1/examples/font-info.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let post_script_name = face.names()
.find(|name| name.name_id() == ttf_parser::name_id::POST_SCRIPT_NAME)
.and_then(|name| name.to_string());
println!("Family name: {:?}", family_name);
println!("PostScript name: {:?}", post_script_name);
println!("Units per EM: {:?}", fac... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/third_party/rust_crates/vendor/ttf-parser-0.10.1/examples/font-info.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /third_party/rust_crates/vendor/ttf-parser-0.10.1/examples/font-info.rs
fn main() {
let args: Vec<_> = std::env::args().collect();
if args.len() != 2 {
println!("Usage:\n\tfont-info font.ttf");
std::process::exit(1);
}
let font_data = std::... | code_fim | medium | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/third_party/rust_crates/vendor/ttf-parser-0.10.1/examples/font-info.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl connection_status_seal::Seal for WindowNavigator {}
impl ConnectionStatus for WindowNavigator {
fn online(&self) -> bool {
self.inner.on_line()
}
}
impl From<web_sys::Navigator> for WindowNavigator {
fn from(inner: web_sys::Navigator) -> Self {
WindowNavigator { inner }
... | code_fim | hard | {
"lang": "rust",
"repo": "RSSchermer/ARWA",
"path": "/arwa/src/window/navigator.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RSSchermer/ARWA path: /arwa/src/window/navigator.rs
use js_sys::Uint32Array;
use wasm_bindgen::{throw_val, JsCast, UnwrapThrowExt};
use crate::connection::{connection_status_seal, ConnectionStatus};
use crate::dom_exception_wrapper;
use crate::geolocation::Geolocation;
use crate::lang::Language... | code_fim | hard | {
"lang": "rust",
"repo": "RSSchermer/ARWA",
"path": "/arwa/src/window/navigator.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: muelli/tor-browser path: /third_party/rust/proc-macro2/src/unstable.rs
use std::ascii;
use std::fmt;
use std::iter;
use std::str::FromStr;
use proc_macro;
use {TokenTree, TokenNode, Delimiter, Spacing};
#[derive(Clone)]
pub struct TokenStream(proc_macro::TokenStream);
pub struct LexError(pro... | code_fim | hard | {
"lang": "rust",
"repo": "muelli/tor-browser",
"path": "/third_party/rust/proc-macro2/src/unstable.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> let filename = FileName(sf.path().to_string());
SourceFile(sf, filename)
}
/// Get the path to this source file as a string.
pub fn path(&self) -> &FileName {
&self.1
}
pub fn is_real(&self) -> bool {
self.0.is_real()
}
}
#[cfg(procmacro2_semver_e... | code_fim | hard | {
"lang": "rust",
"repo": "muelli/tor-browser",
"path": "/third_party/rust/proc-macro2/src/unstable.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pingw33n/czar-old path: /src/semantic/check/lex_path.rs
use super::*;
impl PassImpl<'_> {
pub fn check_path(&mut self, node: NodeId /*PathEndEmpty|PathEndIdent|PathEndStar*/) -> Result<Option<TypeId>> {
// Check `use {self}` case.
if_chain! {
if let Some(path_end... | code_fim | hard | {
"lang": "rust",
"repo": "pingw33n/czar-old",
"path": "/src/semantic/check/lex_path.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn check_path_node_ty_args(&mut self, path: NodeId /*PathEndIdent*/, ty: TypeId) -> Result<TypeId> {
let path_start = self.discover_data.find_path_start(path, self.hir).unwrap();
let fully_inferrable = match self.hir.node_kind(self.discover_data.parent_of(path_start).0).value {
... | code_fim | hard | {
"lang": "rust",
"repo": "pingw33n/czar-old",
"path": "/src/semantic/check/lex_path.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(Solution::roman_to_int("III".into()), 3);
assert_eq!(Solution::roman_to_int("IV".into()), 4);
assert_eq!(Solution::roman_to_int("IX".into()), 9);
assert_eq!(Solution::roman_to_int("LVIII".into()), 58);
assert_eq!(Solution::roman_to_int("MCMXCIV".into()), ... | code_fim | hard | {
"lang": "rust",
"repo": "pkafma-aon/LeetCode-Rust",
"path": "/src/roman_to_integer.rs",
"mode": "spm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pkafma-aon/LeetCode-Rust path: /src/roman_to_integer.rs
impl Solution {
pub fn roman_to_int(s: String) -> i32 {
fn c2i(c: u8) -> i32 {
match c {
b'I' => 1,
b'V' => 5,
b'X' => 10,
b'L' => 50,
b... | code_fim | hard | {
"lang": "rust",
"repo": "pkafma-aon/LeetCode-Rust",
"path": "/src/roman_to_integer.rs",
"mode": "psm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_suffix|> args[0].trim().replace(',', "").parse::<usize>().unwrap()
);
}<|fim_prefix|>// repo: xvxx/hex path: /src/main.rs
use std::env;
fn main() {
let args: Vec<String> = env::args().sk<|fim_middle|>ip(1).collect();
if args.is_empty() {
eprintln!("usage: hex NUMBER");
return;
... | code_fim | medium | {
"lang": "rust",
"repo": "xvxx/hex",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xvxx/hex path: /src/main.rs
use std::env;
fn main() {
let args: Vec<String> = env::args().skip(1).collect();
if args.is_empty() {
eprintln!("usage: he<|fim_suffix|> args[0].trim().replace(',', "").parse::<usize>().unwrap()
);
}<|fim_middle|>x NUMBER");
return;
... | code_fim | medium | {
"lang": "rust",
"repo": "xvxx/hex",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub const PAGE_SIZE: usize = 4096;
type VirtAddr = usize;
type PhysAddr = usize;
use core::ptr::{read_volatile, write_volatile};
#[inline(always)]
pub fn write<T>(addr: usize, content: T) {
let cell = (addr) as *mut T;
unsafe {
write_volatile(cell, content);
}
}
#[inline(always)]
pub... | code_fim | hard | {
"lang": "rust",
"repo": "rcore-os/zCore",
"path": "/drivers/src/bus/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>type VirtAddr = usize;
type PhysAddr = usize;
use core::ptr::{read_volatile, write_volatile};
#[inline(always)]
pub fn write<T>(addr: usize, content: T) {
let cell = (addr) as *mut T;
unsafe {
write_volatile(cell, content);
}
}
#[inline(always)]
pub fn read<T>(addr: usize) -> T {
... | code_fim | medium | {
"lang": "rust",
"repo": "rcore-os/zCore",
"path": "/drivers/src/bus/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rcore-os/zCore path: /drivers/src/bus/mod.rs
#[cfg(any(target_arch = "x86_64", target_arch = "riscv64"))]
pub mod pci;
pub fn phys_to_virt(paddr: PhysAddr) -> VirtAddr {
unsafe { drivers_phys_to_virt(paddr) }
}
pub fn virt_to_phys(vaddr: VirtAddr) -> PhysAddr {
unsafe { drivers_virt_to... | code_fim | medium | {
"lang": "rust",
"repo": "rcore-os/zCore",
"path": "/drivers/src/bus/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Show smallest font with white font on black background
let style = TextStyle {
font: Font6x8,
text_color: Some(BinaryColor::Off),
background_color: Some(BinaryColor::On),
};
Text::new("Hello World! - inverse 6x8", Point::new(15, 30))
.into_styled(style)
... | code_fim | hard | {
"lang": "rust",
"repo": "danielbank/embedded-graphics",
"path": "/simulator/examples/fonts.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: danielbank/embedded-graphics path: /simulator/examples/fonts.rs
use embedded_graphics::egtext;
use embedded_graphics::fonts::{Font12x16, Font6x12, Font6x8, Font8x16, Text};
use embedded_graphics::pixelcolor::BinaryColor;
use embedded_graphics::prelude::*;
use embedded_graphics::style::TextStyle;... | code_fim | medium | {
"lang": "rust",
"repo": "danielbank/embedded-graphics",
"path": "/simulator/examples/fonts.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tauri-apps/tauri path: /tooling/cli/templates/plugin/src/error.rs
{{#if license_header}}
{{ license_header }}
{{/if}}
use serde::{ser::Serializer, Serialize};
pub type Result<T> = std::result::Result<T, Error>;
<|fim_suffix|>impl Serialize for Error {
fn serialize<S>(&self, serializer: S) ->... | code_fim | hard | {
"lang": "rust",
"repo": "tauri-apps/tauri",
"path": "/tooling/cli/templates/plugin/src/error.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error(transparent)]
Io(#[from] std::io::Error),
#[cfg(mobile)]
#[error(transparent)]
PluginInvoke(#[from] tauri::plugin::mobile::PluginInvokeError),
}
impl Serialize for Error {
fn serialize<S>(&self, serializer: S) -> std::result::Result<... | code_fim | medium | {
"lang": "rust",
"repo": "tauri-apps/tauri",
"path": "/tooling/cli/templates/plugin/src/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> where
S: Serializer,
{
serializer.serialize_str(self.to_string().as_ref())
}
}<|fim_prefix|>// repo: tauri-apps/tauri path: /tooling/cli/templates/plugin/src/error.rs
{{#if license_header}}
{{ license_header }}
{{/if}}
use serde::{ser::Serializer, Serialize};
pub type Result<T> = std::resu... | code_fim | medium | {
"lang": "rust",
"repo": "tauri-apps/tauri",
"path": "/tooling/cli/templates/plugin/src/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kenshih/rust-aws-lambda-template path: /src/main.rs
use lambda_runtime::{handler_fn, Context, Error};
use serde_json::{json, Value};
<|fim_suffix|>async fn func(_event: Value, _: Context) -> Result<Value, Error> {
Ok(json!({ "message": format!("Hello, {}!", "{{project-name}}") }))
}<|fim_mi... | code_fim | medium | {
"lang": "rust",
"repo": "kenshih/rust-aws-lambda-template",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>async fn func(_event: Value, _: Context) -> Result<Value, Error> {
Ok(json!({ "message": format!("Hello, {}!", "{{project-name}}") }))
}<|fim_prefix|>// repo: kenshih/rust-aws-lambda-template path: /src/main.rs
use lambda_runtime::{handler_fn, Context, Error};
use serde_json::{json, Value};
<|fim_mi... | code_fim | medium | {
"lang": "rust",
"repo": "kenshih/rust-aws-lambda-template",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>2 || c - b <= 2 {
mn = 1;
}
mx = c - a - 2;
vec![mn, mx]
}
}<|fim_prefix|>// repo: stackcats/leetcode path: /algorithms/medium/moving_stones_until_consecutive.rs
impl Solution {
pub fn num_moves_stones(a: i32, b: i32, c: i32) -> Vec<i32> {
let mut arr =... | code_fim | medium | {
"lang": "rust",
"repo": "stackcats/leetcode",
"path": "/algorithms/medium/moving_stones_until_consecutive.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stackcats/leetcode path: /algorithms/medium/moving_stones_until_consecutive.rs
impl Solution {
pub fn num_moves_stones(a: i32, b: i32, c: i32) -> Vec<i32> {
let mut a<|fim_suffix|>t mut mx = 0;
if b - a == 1 && c - b == 1 {
mn = 0;
} else if b - a <= 2 || ... | code_fim | medium | {
"lang": "rust",
"repo": "stackcats/leetcode",
"path": "/algorithms/medium/moving_stones_until_consecutive.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: assert-rs/predicates-rs path: /src/str/mod.rs
// Copyright (c) 2018 The predicates-rs Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MI... | code_fim | medium | {
"lang": "rust",
"repo": "assert-rs/predicates-rs",
"path": "/src/str/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(feature = "regex")]
mod regex;
#[cfg(feature = "regex")]
pub use self::regex::{is_match, RegexError, RegexPredicate};<|fim_prefix|>// repo: assert-rs/predicates-rs path: /src/str/mod.rs
// Copyright (c) 2018 The predicates-rs Project Developers.
//
// Licensed under the Apache License, Version 2.0 ... | code_fim | hard | {
"lang": "rust",
"repo": "assert-rs/predicates-rs",
"path": "/src/str/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yoojinl/vulkano-www path: /src/lib.rs
// Copyright (c) 2017 The vulkano developers
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT
// license <LICENSE-MIT or http://opensource.org/licenses/MIT>,
// at your option. ... | code_fim | hard | {
"lang": "rust",
"repo": "yoojinl/vulkano-www",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut compil_cache = CACHE.lock().unwrap();
let html = match compil_cache.entry(body) {
Entry::Occupied(e) => e.into_mut(),
Entry::Vacant(e) => {
let data = mustache::MapBuilder::new()
.insert_str("body", e.key())
.build();
... | code_fim | hard | {
"lang": "rust",
"repo": "yoojinl/vulkano-www",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: z22092/sleep-rs path: /build.rs
use std::{fs, io};
const COPILED_FILE: &str = "target/release/libsleep_timer.so";
const NODE_FILE: &str = "index.node";
fn main() {
<|fim_suffix|> let nice = fs::copy(from, to); // Copy foo.txt to bar.txt
nice
}<|fim_middle|> let _ret = cp(COPILED_FILE, NODE... | code_fim | hard | {
"lang": "rust",
"repo": "z22092/sleep-rs",
"path": "/build.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("cargo:rustc-cdylib-link-arg=-undefined");
if cfg!(target_os = "macos") {
println!("cargo:rustc-cdylib-link-arg=dynamic_lookup");
}
}
fn cp(from: &str, to: &str) -> Result<u64, io::Error> {
let nice = fs::copy(from, to); // Copy foo.txt to bar.txt
nice
}<|fim_prefix|>// repo: z2209... | code_fim | easy | {
"lang": "rust",
"repo": "z22092/sleep-rs",
"path": "/build.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jcyongqin/hello_gl_rs path: /hello_gl/src/lib.rs
/// #将主要逻辑写在mod中
extern crate libgl;
extern crate sdl2;
extern crate image;
extern crate cgmath as vm;
#[macro_use]
extern crate lazy_static;
pub use vm::prelude::*;
pub use render_gl::Context;
pub use sdl2::{EventPump, video::Window, video::GLC... | code_fim | hard | {
"lang": "rust",
"repo": "jcyongqin/hello_gl_rs",
"path": "/hello_gl/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn create_window(&self, name: &str, width: u32, height: u32) -> Option<Window> {
let window = self.app.video()
.unwrap()
.window(name, width, height)
.opengl()
.build()
.unwrap();
Some(window)
}
pub fn event_pump(... | code_fim | medium | {
"lang": "rust",
"repo": "jcyongqin/hello_gl_rs",
"path": "/hello_gl/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn set_speed(&mut self, pan: f32, scale: f32) {
self.pan_speed = pan;
self.scale_speed = scale;
}
pub fn update(&mut self, _dt: f32) {
let mut b = self.pan_speed * _dt;
if b > 1.0 {
b = 1.0;
}
let a = 1.0 - b;
self.current.set_translation(self.current.get_translation() * a + self.... | code_fim | medium | {
"lang": "rust",
"repo": "mitresthen/pregamejamgamejam2019",
"path": "/gj2020/src/smooth_transform.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mitresthen/pregamejamgamejam2019 path: /gj2020/src/smooth_transform.rs
use engine::prelude::*;
pub struct SmoothTransform {
pan_speed: f32,
scale_speed: f32,
current: Transform,
target: Transform,
}
impl SmoothTransform {
pub fn new(transform: &Transform, pan_speed: f32, scale_speed: f32)... | code_fim | medium | {
"lang": "rust",
"repo": "mitresthen/pregamejamgamejam2019",
"path": "/gj2020/src/smooth_transform.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(transformation(b"t 1 2 3\n"), IResult::Done(&b""[..], Transformation::Translation(1.0, 2.0, 3.0)));
assert_eq!(transformation(b"r 1 2 3 1\n"), IResult::Done(&b""[..], Transformation::Rotation(1.0, 2.0, 3.0, 1.0)));
assert_eq!(transformation(b"s 1 2 3\n"), IResult::Done(&... | code_fim | hard | {
"lang": "rust",
"repo": "cptroot/CS171_clean",
"path": "/parse/src/transformation.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cptroot/CS171_clean path: /parse/src/transformation.rs
use nalgebra::{Matrix4, Vector3, Unit, U4, MatrixArray, Matrix};
use nom::{space, line_ending};
use types::float;
#[derive(Clone, Copy, PartialEq, Debug)]
pub enum Transformation {
Translation(f32, f32, f32),
Rotation(f32, f32, f32... | code_fim | hard | {
"lang": "rust",
"repo": "cptroot/CS171_clean",
"path": "/parse/src/transformation.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>named!(pub transformation<&[u8], Transformation>,
alt!(
do_parse!(
tag!("t") >>
space >>
x: float >>
space >>
y: float >>
space >>
z: float >>
line_ending >>
... | code_fim | hard | {
"lang": "rust",
"repo": "cptroot/CS171_clean",
"path": "/parse/src/transformation.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> intrinsics::index(self.name()).unwrap()
}
/// Type and arity information for the intrinsic
fn info(&self) -> &intrinsics::Intrinsic {
intrinsics::intrinsic(self.index())
}
/// An intrinsic has mutable access to the machine
///
/// A call to an intrinsic may as... | code_fim | hard | {
"lang": "rust",
"repo": "curvelogic/eucalypt",
"path": "/src/eval/machine/intrinsic.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: curvelogic/eucalypt path: /src/eval/machine/intrinsic.rs
//! Intrinsic traits
use std::rc::Rc;
use lru::LruCache;
use regex::Regex;
use crate::{
common::sourcemap::Smid,
eval::stg::wrap::wrap,
eval::{
emit::Emitter,
error::ExecutionError,
intrinsics,
... | code_fim | hard | {
"lang": "rust",
"repo": "curvelogic/eucalypt",
"path": "/src/eval/machine/intrinsic.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Mubelotix/dkim path: /src/parsing/quoted_printable.rs
use crate::parsing::tag_value_list::{is_valchar, is_wsp};
use crate::parsing::ParsingError;
/// Read a string encoded with dkim-quoted-printable.
pub fn from_dqp(input: &str) -> nom::IResult<&str, String, ParsingError> {
let mut chars = ... | code_fim | hard | {
"lang": "rust",
"repo": "Mubelotix/dkim",
"path": "/src/parsing/quoted_printable.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_dkim_quoted_printable_generation_and_parsing() {
assert_eq!(from_dqp(&into_dqp("Ces territoires ont des statuts variés dans l'administration territoriale de la France et sont situés : ")).unwrap().1, "Ces territoires ont des statuts variés dans l'administration territoriale... | code_fim | hard | {
"lang": "rust",
"repo": "Mubelotix/dkim",
"path": "/src/parsing/quoted_printable.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(from_dqp(&into_dqp("Au nord s'étend la vaste forêt de Cussangy d'enviton 800 hectares, qui se poursuit jusqu'à Chaource. C'est une forêt de feuillus essentiellement : chênes, charmes, acacias, bouleaux, merisiers. Les bois sont soit communaux (270 hectares environ) ou privés.")).unwrap(... | code_fim | hard | {
"lang": "rust",
"repo": "Mubelotix/dkim",
"path": "/src/parsing/quoted_printable.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pimox/proxmox path: /proxmox/src/tools/uuid.rs
//! Simple bindings to libuuid's `uuid_generate`.
use std::borrow::{Borrow, BorrowMut};
use std::fmt;
use anyhow::{bail, Error};
use serde::{Serialize, Serializer};
use crate::tools::parse::hex_nibble;
#[link(name = "uuid")]
extern "C" {
fn ... | code_fim | hard | {
"lang": "rust",
"repo": "pimox/proxmox",
"path": "/proxmox/src/tools/uuid.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> *self.0
}
}
impl fmt::Display for Uuid {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::LowerHex::fmt(self, f)
}
}
impl fmt::LowerHex for Uuid {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut buf = [0u8; 37];
unsafe {
... | code_fim | hard | {
"lang": "rust",
"repo": "pimox/proxmox",
"path": "/proxmox/src/tools/uuid.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self::parse_str(src)
}
}
impl Serialize for Uuid {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let mut buf = [0u8; 37];
unsafe {
uuid_unparse_lower(self.as_bytes(), buf.as_mut_ptr());
}
... | code_fim | hard | {
"lang": "rust",
"repo": "pimox/proxmox",
"path": "/proxmox/src/tools/uuid.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_parse_fastq() {
let bytes = b"@id1 desc \nTTTTTTAAAAAA\n+\nFFFFFFFFFFFFF\n@id2\nGGGGGGCCCCCC\n+\nFFFFFFFFFFFFF\n";
let (rest, record1) = parse_single_fastq(bytes).unwrap();
let (_, record2) = parse_single_fastq(res... | code_fim | hard | {
"lang": "rust",
"repo": "eclarke/fastx",
"path": "/src/internals.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eclarke/fastx path: /src/internals.rs
use std::str;
use itertools::Itertools;
use nom::{not_line_ending, line_ending, rest};
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Clone)]
pub struct Record {
pub id: String,
pub seq: Vec<u8>,
pub qual: Option<Vec<u8>>
}
impl Record {
... | code_fim | medium | {
"lang": "rust",
"repo": "eclarke/fastx",
"path": "/src/internals.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_parse_fastq() {
let bytes = b"@id1 desc \nTTTTTTAAAAAA\n+\nFFFFFFFFFFFFF\n@id2\nGGGGGGCCCCCC\n+\nFFFFFFFFFFFFF\n";
let (rest, record1) = parse_single_fastq(bytes).unwrap();
let (_, record2) = parse_single_fastq(rest).unwrap();
let rec1 = Record{id:St... | code_fim | hard | {
"lang": "rust",
"repo": "eclarke/fastx",
"path": "/src/internals.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: intdxdt/robust_scale path: /src/lib.rs
extern crate two_sum;
extern crate two_product;
use two_sum::two_sum;
use two_product::two_product;
pub fn robust_scale(e: &[f64], scale: f64) -> Vec<f64> {
linear_expansion(e, scale)
}
fn linear_expansion(e: &[f64], scale: f64) -> Vec<f64> {
let... | code_fim | hard | {
"lang": "rust",
"repo": "intdxdt/robust_scale",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_robust_scale() {
assert_eq!(robust_scale(&vec!(4.), 2.), [8.]);
assert_eq!(robust_scale(&vec!(1., 1e64), 2.), [2., 2e64]);
assert_eq!(robust_scale(&vec!(1.), 1.), [1.]);
let s = robust_scale(
&vec!(-2.4707339790384e-144, -1.64010647157399... | code_fim | hard | {
"lang": "rust",
"repo": "intdxdt/robust_scale",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kyasu1/kuon path: /examples/timeline.rs
use anyhow::Result;
#[tokio::main]
async fn main() -> Result<()> {
let api: kuon::TwitterAPI = kuon::TwitterAPI::new_using_env().await?;
let res = api
.user_timeline()
.screen_name("rustlang")
.count(10)
.send()
... | code_fim | medium | {
"lang": "rust",
"repo": "kyasu1/kuon",
"path": "/examples/timeline.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let res = api.home_timeline().count(10).send().await?;
for tweet in res {
println!("{}", tweet.text);
// show original quality images' url
if let Some(extended_entities) = tweet.extended_entities {
for media in extended_entities.media {
println!... | code_fim | medium | {
"lang": "rust",
"repo": "kyasu1/kuon",
"path": "/examples/timeline.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for tweet in res {
println!("{}", tweet.text);
// show original quality images' url
if let Some(extended_entities) = tweet.extended_entities {
for media in extended_entities.media {
println!("{}:orig", media.media_url_https)
}
}
... | code_fim | medium | {
"lang": "rust",
"repo": "kyasu1/kuon",
"path": "/examples/timeline.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shekohex/facetract path: /src/lib.rs
#![deny(
unsafe_code,
missing_debug_implementations,
missing_copy_implementations,
elided_lifetimes_in_paths,
rust_2018_idioms,
clippy::fallible_impl_from,
clippy::missing_const_for_fn
)]
use image::{GenericImageView, Pixel};
use ... | code_fim | hard | {
"lang": "rust",
"repo": "shekohex/facetract",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// How likely it is a Human Face
pub const fn probability(&self) -> f32 { self.prob }
}
#[derive(Debug)]
pub struct FaceTract {
graph: Graph,
min_size: f32,
factor: f32,
thresholds: [f32; 3],
}
impl Default for FaceTract {
fn default() -> Self { Self::new(40.0, 0.709, [0.6, ... | code_fim | hard | {
"lang": "rust",
"repo": "shekohex/facetract",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shaneutt/krustlet path: /crates/kubelet/src/resources/mod.rs
//! `resources` contains utilities and managers for container resources.
<|fim_suffix|>pub use device_plugin_manager::manager::DeviceManager;
pub mod util;<|fim_middle|>pub(crate) mod device_plugin_manager;
pub(crate) mod quantity;
| code_fim | medium | {
"lang": "rust",
"repo": "shaneutt/krustlet",
"path": "/crates/kubelet/src/resources/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use device_plugin_manager::manager::DeviceManager;
pub mod util;<|fim_prefix|>// repo: shaneutt/krustlet path: /crates/kubelet/src/resources/mod.rs
//! `resources` contains utilities and managers for container resources.
<|fim_middle|>pub(crate) mod device_plugin_manager;
pub(crate) mod quantity;
| code_fim | medium | {
"lang": "rust",
"repo": "shaneutt/krustlet",
"path": "/crates/kubelet/src/resources/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jawline/Mimic path: /src/headless.rs
use std::error::Error;
use std::sync::mpsc;
use std::time::Instant;
use rand::{rngs::ThreadRng, thread_rng, Rng};
use crate::machine::Machine;
use crate::ppu::{PpuStepState, GB_SCREEN_HEIGHT, GB_SCREEN_WIDTH};
use log::info;
enum State {
Startup,
Obser... | code_fim | hard | {
"lang": "rust",
"repo": "jawline/Mimic",
"path": "/src/headless.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Clear the sound RX (ideally sound will be switched off)
while let Ok(_) = sound_rx.try_recv() {}
match state {
PpuStepState::VBlank => {
frames = frames + 1;
total_frames = total_frames + 1;
if total_frames % 60 == 0 {
seconds += 1;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "jawline/Mimic",
"path": "/src/headless.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match current_state {
State::Startup => {
if seconds_since_last_transition > 10 {
println!("OBSERVING");
current_state = State::Observing;
last_state_transition = seconds;
}
}
State::Observing => {
... | code_fim | hard | {
"lang": "rust",
"repo": "jawline/Mimic",
"path": "/src/headless.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: quark-zju/sndcat path: /src/output/dev.rs
use crate::mixer::Samples;
use crate::mixer::StreamInfo;
use crate::output::Output;
use crate::output::OutputWriter;
use portaudio::stream::OutputSettings;
use portaudio::stream::Parameters;
use portaudio::DeviceIndex;
use portaudio::PortAudio;
use std::... | code_fim | hard | {
"lang": "rust",
"repo": "quark-zju/sndcat",
"path": "/src/output/dev.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl OutputWriter for DeviceOutput {
fn write(&mut self, samples: Arc<Samples>) -> anyhow::Result<()> {
let samples = crate::mixer::normalize_cow(samples, self.info, &mut self.resampler)?;
// https://portaudio.music.columbia.narkive.com/nLRsY3jZ/thread-safety-of-blocking-calls
... | code_fim | hard | {
"lang": "rust",
"repo": "quark-zju/sndcat",
"path": "/src/output/dev.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Solution {
pub fn defang_i_paddr(address: String) -> String {
str::replace(&address[..], ".", "[.]")
}
}<|fim_prefix|>// repo: szhongren/leetcode path: /1108/main.rs
fn main() {
println!("{}", Solution::defang_i_paddr("127.0.0.1".to_string()));
}
<|fim_middle|>struct Sol... | code_fim | easy | {
"lang": "rust",
"repo": "szhongren/leetcode",
"path": "/1108/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: szhongren/leetcode path: /1108/main.rs
fn main() {
println!("{}", Solution::defang_i_paddr("127.0.0.1".to_string()));
}
<|fim_suffix|>impl Solution {
pub fn defang_i_paddr(address: String) -> String {
str::replace(&address[..], ".", "[.]")
}
}<|fim_middle|>struct Sol... | code_fim | easy | {
"lang": "rust",
"repo": "szhongren/leetcode",
"path": "/1108/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andoriyu/material-design-icons-rs path: /src/materialicons/action/icon_remove_done.rs
pub struct IconRemoveDone {
props: crate::Props,
}
impl yew::Component for IconRemoveDone {
type Properties = crate::Props;
type Message = ();
fn create(props: Self::Properties, _: yew::prelude::C... | code_fim | hard | {
"lang": "rust",
"repo": "andoriyu/material-design-icons-rs",
"path": "/src/materialicons/action/icon_remove_done.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Haroenv/gedcomx-date-rs path: /src/parsers/range.rs
use super::super::{GedcomxDate, Range};
use super::approximate;
use super::simple::datetime;
use super::{datetime_or_duration, parse_datetime};
<|fim_suffix|>named!(pub range <GedcomxDate>,
chain!(
a: opt!(approximate) ~
d... | code_fim | medium | {
"lang": "rust",
"repo": "Haroenv/gedcomx-date-rs",
"path": "/src/parsers/range.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>named!(pub range <GedcomxDate>,
chain!(
a: opt!(approximate) ~
dates: alt_complete!(
chain!(start:datetime ~ complete!(range_marker) ~ end:datetime_or_duration, || (Some(start), Some(end))) |
chain!(complete!(range_marker) ~ end:parse_datetime, || (None, Some(en... | code_fim | medium | {
"lang": "rust",
"repo": "Haroenv/gedcomx-date-rs",
"path": "/src/parsers/range.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let CutShift { mag, motion } = self;
let mut pos = tui.cursor;
for _ in 0..*mag {
if let Some(cursor) = motion.move_cursor(&tui.cmd, pos) {
pos = cursor;
}
}
if pos != tui.cursor {
let (low, high) = (min(pos, tui... | code_fim | medium | {
"lang": "rust",
"repo": "eulegang/er-rusted",
"path": "/src/ui/tui/action/shift.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eulegang/er-rusted path: /src/ui/tui/action/shift.rs
use super::Action;
use crate::ui::tui::{motion::Motion, Tui};
use std::cmp::{max, min};
pub struct Shift<M: Motion> {
pub mag: usize,
pub motion: M,
}
<|fim_suffix|> tui.draw_cmd()?.draw_cursor()?;
Ok(())
}
}
imp... | code_fim | hard | {
"lang": "rust",
"repo": "eulegang/er-rusted",
"path": "/src/ui/tui/action/shift.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut pos = tui.cursor;
for _ in 0..*mag {
if let Some(cursor) = motion.move_cursor(&tui.cmd, pos) {
pos = cursor;
}
}
if pos != tui.cursor {
let (low, high) = (min(pos, tui.cursor), max(pos, tui.cursor));
... | code_fim | hard | {
"lang": "rust",
"repo": "eulegang/er-rusted",
"path": "/src/ui/tui/action/shift.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mas-yo/rustcs-test path: /main/src/main.rs
use libc::{dlopen, dlsym};
use libloading;
use std::env::*;
use std::ffi::CString;
use std::fs::{self, DirEntry};
use std::io;
use std::mem;
use std::os::raw::*;
use std::path::Path;
use std::prelude::*;
use std::ptr;
use std::time::{Duration, Instant};... | code_fim | hard | {
"lang": "rust",
"repo": "mas-yo/rustcs-test",
"path": "/main/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let property_values: [*const c_char; 1] = [tpa_list.as_ptr()];
let host_handle: *const c_void = ptr::null();
let domain_id: c_uint = 0;
let self_path = cstring(current_exe().unwrap().to_str().unwrap());
let Game = cstring("main");
let result = coreclr_initialize(
self_pa... | code_fim | hard | {
"lang": "rust",
"repo": "mas-yo/rustcs-test",
"path": "/main/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let sdl_context = sdl2::init().unwrap();
let audio_subsystem = sdl_context.audio().unwrap();
let desired_spec = AudioSpecDesired {
freq: Some(44100),
channels: Some(1), // mono
samples: None // default sample size
};
let device = audio_subsy... | code_fim | hard | {
"lang": "rust",
"repo": "fzzzy/rust-synth",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fzzzy/rust-synth path: /src/main.rs
// This is the example code modified from rust-sdl2/src/sdl2/audio.rs
// It now generates a sine wave instead of a square wave
extern crate sdl2;
use sdl2::audio::{AudioCallback, AudioSpecDesired};
use std::time::Duration;
use std::f32::consts::PI;
struct S... | code_fim | medium | {
"lang": "rust",
"repo": "fzzzy/rust-synth",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Generate a sin wave
for x in out.iter_mut() {
*x = f32::sin(self.phase);
self.phase = self.phase + self.phase_inc;
}
}
}
fn main() {
let sdl_context = sdl2::init().unwrap();
let audio_subsystem = sdl_context.audio().unwrap();
let desired... | code_fim | medium | {
"lang": "rust",
"repo": "fzzzy/rust-synth",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Spread0x/rome path: /crates/rome_js_formatter/src/js/unknown/mod.rs
//! Generated file, do not edit by hand, see `xtask/codegen`
#[allow(clippy::module_inception)]
pub(cr<|fim_suffix|> mod unknown_named_import_specifier;
pub(crate) mod unknown_parameter;
pub(crate) mod unknown_statement;<|fim_m... | code_fim | hard | {
"lang": "rust",
"repo": "Spread0x/rome",
"path": "/crates/rome_js_formatter/src/js/unknown/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> mod unknown_named_import_specifier;
pub(crate) mod unknown_parameter;
pub(crate) mod unknown_statement;<|fim_prefix|>// repo: Spread0x/rome path: /crates/rome_js_formatter/src/js/unknown/mod.rs
//! Generated file, do not edit by hand, see `xtask/codegen`
#[allow(clippy::module_inception)]
pub(crate) mo... | code_fim | medium | {
"lang": "rust",
"repo": "Spread0x/rome",
"path": "/crates/rome_js_formatter/src/js/unknown/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>own_expression;
pub(crate) mod unknown_import_assertion_entry;
pub(crate) mod unknown_member;
pub(crate) mod unknown_named_import_specifier;
pub(crate) mod unknown_parameter;
pub(crate) mod unknown_statement;<|fim_prefix|>// repo: Spread0x/rome path: /crates/rome_js_formatter/src/js/unknown/mod.rs
//! Ge... | code_fim | medium | {
"lang": "rust",
"repo": "Spread0x/rome",
"path": "/crates/rome_js_formatter/src/js/unknown/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn get_fits() -> &'static FitData {
&FITS
}
pub fn used_module_ids() -> Vec<TypeID> {
let mut ids = BTreeSet::new();
for (&hull, fits) in get_fits() {
ids.insert(hull);
for fit in fits {
for &id in fit.fit.modules.keys() {
ids.insert(id);
... | code_fim | hard | {
"lang": "rust",
"repo": "Aquanable/waitlist",
"path": "/backend/src/data/fits.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Aquanable/waitlist path: /backend/src/data/fits.rs
use regex::Regex;
use std::collections::{BTreeSet, HashMap};
use eve_data_core::{Fitting, TypeID};
type FitData = HashMap<TypeID, Vec<DoctrineFit>>;
lazy_static::lazy_static! {
static ref FITS: FitData = load_fits();
}
#[derive(Debug)]
p... | code_fim | hard | {
"lang": "rust",
"repo": "Aquanable/waitlist",
"path": "/backend/src/data/fits.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chris-zen/hero-synth path: /studio/src/midi/events.rs
// use std::slice::Iter;
use midi::messages::Message;
use midi::types::Timestamp;
#[derive(Clone, Eq, PartialEq)]
pub struct Event {
timestamp: Timestamp,
message: Message
}
impl Event {
pub fn new(timestamp: Timestamp, message... | code_fim | hard | {
"lang": "rust",
"repo": "chris-zen/hero-synth",
"path": "/studio/src/midi/events.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone)]
pub struct PortEvents {
port: String,
events: Vec<Event>
}
impl PortEvents {
pub fn new(port: &str, events: Vec<Event>) -> PortEvents {
PortEvents {
port: port.to_string(),
events: events
}
}
#[inline]
pub fn port(&self) ->... | code_fim | medium | {
"lang": "rust",
"repo": "chris-zen/hero-synth",
"path": "/studio/src/midi/events.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.