blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 5 140 | path stringlengths 5 183 | src_encoding stringclasses 6
values | length_bytes int64 12 5.32M | score float64 2.52 4.94 | int_score int64 3 5 | detected_licenses listlengths 0 47 | license_type stringclasses 2
values | text stringlengths 12 5.32M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
d362771f5482481f5b8437afc95bc6fce49770ea | Rust | yurrriq/exercism | /rust/magazine-cutout/src/lib.rs | UTF-8 | 635 | 2.953125 | 3 | [] | no_license | use std::collections::hash_map::Entry;
use std::collections::HashMap;
pub fn can_construct_note(magazine: &[&str], note: &[&str]) -> bool {
let mut magazine_words =
magazine.iter().fold(HashMap::new(), |mut words, word| {
*words.entry(word).or_insert(0) += 1;
words
});
... | true |
cffa109c7b57dc5e6f750907b431584b571442dd | Rust | flegac/rust-mcts | /mini-nn/src/framework/metric.rs | UTF-8 | 525 | 3.125 | 3 | [] | no_license | use std::iter::FromIterator;
use itertools::zip;
pub trait Metric<T> {
fn score(lhs: &T, rhs: &T) -> f32;
fn score_map(lhs: &T, rhs: &[T]) -> f32 {
let mut res = 0_f32;
for i in 0..rhs.len() {
let delta = Self::score(lhs, &rhs[i]);
res += delta * delta;
}
... | true |
8282e1140dc5ef34c2f1bfdd5ff31c036a53902d | Rust | dimforge/rapier | /src/pipeline/physics_hooks.rs | UTF-8 | 12,086 | 2.890625 | 3 | [
"Apache-2.0"
] | permissive | use crate::dynamics::{RigidBodyHandle, RigidBodySet};
use crate::geometry::{ColliderHandle, ColliderSet, ContactManifold, SolverContact, SolverFlags};
use crate::math::{Real, Vector};
use na::ComplexField;
/// Context given to custom collision filters to filter-out collisions.
pub struct PairFilterContext<'a> {
//... | true |
5ed5992127fa67f0f345b587d886fb38d75e472c | Rust | gabi-250/rust | /src/librustc_codegen_ironox/global.rs | UTF-8 | 639 | 3.0625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-other-permissive",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | use ir::type_::Type;
use ir::value::Value;
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub struct Global {
pub ty: Type,
pub name: String,
pub constant: bool,
pub initializer: Option<Value>,
}
impl Global {
pub fn new(ty: Type, name: String) -> Global {
Global { ty, name, constant: false,... | true |
c27b15c05fd81090364ab94c22396bd7d3a945e2 | Rust | CJHJ/rust-tutorial | /ownership/src/main.rs | UTF-8 | 1,355 | 4.5 | 4 | [] | no_license | fn main() {
// Move
let s1 = String::from("hello");
let s2 = s1; // s1 will be freed, data from s1 will be copied to s2.
println!("s2 = {}", s2);
// Clone - deep copy
let s1 = String::from("hello");
let s2 = s1.clone();
println!("s1 = {}, s2 = {}", s1, s2);
// Primitive (type with ... | true |
921a3842622ab2ffddcbbec95a186656d7a74c6b | Rust | henrikland/advent2020 | /day10/10-2.rs | UTF-8 | 1,120 | 3.0625 | 3 | [] | no_license | use std::io::{self, Read};
use std::cmp::min;
fn parse_input(input: &String) -> Vec<u32> {
input
.split("\n")
.map(|line| line.parse::<u32>().unwrap())
.collect::<Vec<u32>>()
}
fn paths_for_index(adapter_index: usize, adapters: &Vec<u32>, cache: &mut Vec<u64>) -> u64 {
if cache[adapter_index] != 0 {
... | true |
a2a4c44657fdb7695e3a49f72ba3e0ff7bcb3f87 | Rust | haraldmaida/lamcal | /src/combinator.rs | UTF-8 | 5,650 | 3.046875 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! [Standard term]s and [combinator]s
//!
//! This module defines [standard term]s and [combinator]s with commonly
//! accepted names. A combinator is a closed lambda expression, meaning that it
//! has no free variables.
//!
//! The combinators are collected from these sources:
//!
//! * [SKI] system by Moses Schönfi... | true |
17a848855ac580de9a9644e6e0d539b5731ea65c | Rust | AvaCity/avacity-test | /src/encoder.rs | UTF-8 | 3,099 | 3.09375 | 3 | [
"BSD-3-Clause"
] | permissive | use std::collections::HashMap;
use crate::common;
use bytes::{BytesMut, BufMut};
pub fn encode(data: &Vec<common::Value>, type_: u8) -> Result<Vec<u8>, &'static str> {
let mut out = BytesMut::new();
out.put_u8(type_);
out.put_i32(data.len() as i32);
for item in data {
let tmp = encode_value(&it... | true |
07f6de5b3bb62ab3ddd88ea4e6204b51a1bb840c | Rust | lesurp/OptionalStruct | /tests/simple.rs | UTF-8 | 604 | 3.171875 | 3 | [
"Apache-2.0"
] | permissive | use optional_struct::*;
#[optional_struct]
struct Config {
delay: Option<u32>,
path: String,
percentage: f32,
}
#[test]
fn test_apply_options() {
let mut config = Config {
delay: Some(2),
path: "/var/log/foo.log".to_owned(),
percentage: 3.12,
};
let opt_config = Option... | true |
d40282338466df97182e744f8f6ff314f9b1af69 | Rust | SOF3/strum | /strum_tests/tests/serialize_all.rs | UTF-8 | 1,007 | 3.21875 | 3 | [
"MIT"
] | permissive | /// test serialize_all cooperation with other macroses
use std::str::FromStr;
use std::string::ToString;
use strum::{EnumString, IntoStaticStr, ToString};
#[derive(Debug, Eq, PartialEq, EnumString, ToString, IntoStaticStr)]
#[strum(serialize_all = "title_case")]
enum Foo1 {
DarkBlack,
Dim { glow: usize },
... | true |
6c4720696c0efa8181faffbc3c0da6f6ae0ae29b | Rust | rust-lang/cargo | /src/cargo/core/compiler/unit.rs | UTF-8 | 9,415 | 3.140625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"GPL-2.0-only",
"Apache-2.0",
"MIT",
"GCC-exception-2.0",
"BSD-3-Clause",
"LGPL-2.0-or-later",
"Zlib",
"OpenSSL",
"curl",
"LGPL-2.1-only",
"BSD-2-Clause",
"LicenseRef-scancode-ssleay-windows",
"Unlicense"
] | permissive | //! Types and impls for [`Unit`].
use crate::core::compiler::unit_dependencies::IsArtifact;
use crate::core::compiler::{CompileKind, CompileMode, CompileTarget, CrateType};
use crate::core::manifest::{Target, TargetKind};
use crate::core::profiles::Profile;
use crate::core::Package;
use crate::util::hex::short_hash;
u... | true |
52299f41a28d51a2287b0c6f27af850843e42e09 | Rust | derrickbaldwin/euler-project | /rust/problem_49/src/main.rs | UTF-8 | 778 | 2.71875 | 3 | [] | no_license | extern crate problem_49;
extern crate primes;
extern crate itertools;
use problem_49::sort_digit;
use primes::is_prime;
use std::collections::HashSet;
fn main() {
let initial_primes = (1000u64..3340).filter(|&x| is_prime(x))
.collect::<Vec<_>>();
let eligible_primes = ... | true |
95cd40c67f6bf155e7bdda8928ea32dc589a2719 | Rust | MathiasPius/pius-blog | /src/highlighter.rs | UTF-8 | 3,836 | 2.859375 | 3 | [] | no_license | use std::cmp::max;
use std::path::Path;
use std::io::BufRead;
use std::collections::HashMap;
use tera::{Result, Value};
use syntect::{
parsing::SyntaxSet,
html::{
IncludeBackground,
start_highlighted_html_snippet,
append_highlighted_html_for_styled_line
},
highlighting::{Color, T... | true |
958fb573f609b007b85ffde63029b9bd05fcf896 | Rust | JoshOrndorff/advent-of-code-2019 | /day14/src/main.rs | UTF-8 | 8,927 | 3.234375 | 3 | [] | no_license | use std::{
collections::{HashMap, HashSet},
convert::TryInto,
fs,
};
mod parser;
#[derive(Hash, Debug, PartialEq, Eq, Clone)]
struct Reagent {
//TODO should I be using &str everywhere?
name: String,
quantity: u64,
}
fn needs_with_fuel(amt: u64) -> HashMap<String, u64> {
let mut s = HashMap... | true |
51dabf0db9887009ca8a0a15f5d1d0956c0145d7 | Rust | LmfZoozle/Zle_Edition3 | /compiler/src/parser.rs | UTF-8 | 4,622 | 3.09375 | 3 | [] | no_license | use super::lexer::Token::*;
use super::lexer::*;
use super::*;
fn consume_number(itr: &mut std::slice::Iter<Token>) -> Option<i32> {
let mut clo = itr.clone();
if let Some(actual) = clo.next() {
if let Token::Number(num) = *actual {
itr.next();
Some(num)
} else {
... | true |
f59cca2a37a3e8402f08266ac66308144ddfd859 | Rust | magiclen/whois-rust | /src/lib.rs | UTF-8 | 1,867 | 2.71875 | 3 | [
"MIT"
] | permissive | /*!
# WHOIS Rust
This is a WHOIS client library for Rust, inspired by https://github.com/hjr265/node-whois
## Usage
You can make a **servers.json** file or copy one from https://github.com/hjr265/node-whois
This is a simple example of **servers.json**.
```json
{
"org": "whois.pir.org",
"": "whois.ripe.net"... | true |
9896b88d1b35bfb29903669139738a9ce58ee22a | Rust | p0lunin/rencan | /rencan-core/src/light/info.rs | UTF-8 | 279 | 2.96875 | 3 | [] | no_license | use nalgebra::Point4;
#[derive(Debug, Clone)]
pub struct LightInfo {
/// RGBA in range [0; 1]
pub color: Point4<f32>,
pub intensity: f32,
}
impl LightInfo {
pub fn new(color: Point4<f32>, intensity: f32) -> Self {
LightInfo { color, intensity }
}
}
| true |
8e42ca6f8f612753af6937ba5043a1662aeac67e | Rust | t-veor/adventofcode | /2017/day20/day20.rs | UTF-8 | 7,722 | 2.921875 | 3 | [] | no_license | #!/usr/bin/env rust-script
//! ```cargo
//! [package]
//! edition = "2021"
//! ```
use std::{collections::HashSet, ops::Add};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
struct IVec3 {
x: i64,
y: i64,
z: i64,
}
impl IVec3 {
fn manhattan_to_origin(self) -> i64 {
self.x.abs() ... | true |
1a1d302825dba25d733b0245e0543b8c9c5f02fe | Rust | barnex/hamstr-game | /src/editor/toolbar.rs | UTF-8 | 1,999 | 3 | 3 | [] | no_license | use super::prelude::*;
use crate::prelude::*;
/// The Toolbar allows the user to pick bloks in edit mode.
pub struct Toolbar {
screen_pos: Pt,
pub columns: i32,
buttons: Vec<Texture>,
tex_selected: Texture,
selected: usize,
}
impl Toolbar {
pub fn new(screen_pos: Pt, palette: Vec<Texture>) -> Self {
Self {
... | true |
1061bfd63bb36b4b96f7e428ad733fa690ec71f7 | Rust | wlindley/advent2018 | /seventh/two/src/main.rs | UTF-8 | 10,521 | 3.0625 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
const DEPENDER_INDEX: usize = 5;
const DEPENDEE_INDEX: usize = 36;
fn main() {
let relationships: Vec<Relationship> = read_input().iter().map(parse_line).collect();
let graph = build_graph(&relationships);
l... | true |
6b947f03bd30c65174296cb92abd3ea93d91ad42 | Rust | alacritty/alacritty | /alacritty_config/src/lib.rs | UTF-8 | 1,385 | 2.875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::collections::HashMap;
use std::error::Error;
use log::LevelFilter;
use serde::Deserialize;
use toml::Value;
pub trait SerdeReplace {
fn replace(&mut self, value: Value) -> Result<(), Box<dyn Error>>;
}
macro_rules! impl_replace {
($($ty:ty),*$(,)*) => {
$(
impl SerdeReplace for $... | true |
17071fcd9dad4cd887c383bf2c3404aad9a52392 | Rust | schedutron/ion-1 | /src/lib/builtins/status.rs | UTF-8 | 2,411 | 2.65625 | 3 | [
"MIT"
] | permissive | use builtins::man_pages::{print_man, MAN_STATUS};
use shell::Shell;
use std::env;
bitflags! {
struct Flags : u8 {
const HELP = 1;
const LOGIN_SHELL = 2;
const INTERACTIVE = 4;
const FILENAME = 8;
}
}
pub(crate) fn status(args: &[&str], shell: &mut Shell) -> Result<(), String> ... | true |
5fb9f6237939cea828e79956c687b15f9f9ecd9e | Rust | deltachat/lettre | /lettre/examples/smtp_gmail.rs | UTF-8 | 985 | 2.78125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | extern crate lettre;
use lettre::smtp::authentication::Credentials;
use lettre::{EmailAddress, Envelope, SendableEmail, SmtpClient, Transport};
fn main() {
let email = SendableEmail::new(
Envelope::new(
Some(EmailAddress::new("from@gmail.com".to_string()).unwrap()),
vec![EmailAddre... | true |
6dfc403619d3ac347dd61e352dfc8316c9da10e3 | Rust | binh-vu/semantic-modeling | /mira/src/assembling/ranking/ranking_features/coherence.rs | UTF-8 | 1,187 | 2.578125 | 3 | [
"MIT"
] | permissive | use algorithm::data_structure::graph::Graph;
use rdb2rdf::models::semantic_model::SemanticModel;
use settings::Settings;
use assembling::auto_label;
use evaluation_metrics::semantic_modeling::DataNodeMode;
use rayon::prelude::*;
#[derive(Clone)]
pub struct Coherence {
max_permutation: usize,
gold_graphs: Vec<G... | true |
cb355541dd0ee09c079d6e0f6aa85e40c691fd58 | Rust | aptend/leetcode-rua | /Rust/src/n1189_maximum_number_of_ballons.rs | UTF-8 | 713 | 3.359375 | 3 | [] | no_license | use std::cmp::min;
use std::collections::HashMap;
pub fn max_number_of_balloons(text: String) -> i32 {
let mut counter: HashMap<char, i32> = HashMap::new();
for ch in text.chars() {
*counter.entry(ch).or_insert(0) += 1
}
let mut ans = text.len() as i32;
for ch in "ban".chars() {
ans... | true |
6415c330b5498f20bd7d6a54c647e98f4f9a792c | Rust | digyx/Catherine | /src/lexer/mod.rs | UTF-8 | 2,215 | 3.703125 | 4 | [
"MIT"
] | permissive | pub mod token;
use token::TokenType;
pub struct Lexer {
input: String,
position: u32,
read_position: u32,
ch: char,
}
impl Lexer {
pub fn next_token(&mut self) -> token::Token {
if self.read_position == self.input.len() as u32 {
return token::new(String::new(), TokenType::EOF... | true |
22a769b9cdc03fba8901a29d94a2db15eebc7d85 | Rust | mystor/nostd-error-poc | /fakecore/src/any.rs | UTF-8 | 3,356 | 3.375 | 3 | [] | no_license | use core::any::TypeId;
use core::cell::Cell;
use core::fmt;
use core::marker::PhantomData;
use core::pin::Pin;
/// A dynamic request for an object based on its type.
///
/// `'out` is the lifetime of the requested reference.
#[repr(transparent)]
pub struct Request<'out>(RequestBuf<PhantomData<&'out Cell<()>>>);
// FIX... | true |
74a41f17d04659dc5cc1e852c8ca9f0cb7947461 | Rust | smbas/simple-ray-tracer | /src/main.rs | UTF-8 | 3,286 | 2.765625 | 3 | [
"MIT"
] | permissive | mod geometry;
mod tracing;
mod material;
mod utils;
use rand::prelude::*;
use geometry::{Vector3, Sphere};
use tracing::{HitWorld, Camera};
use material::{Lambertian, Metal, Dielectric};
fn main() {
let nx = 800;
let ny = 400;
let ns = 20;
println!("P3\n{} {}\n255", nx, ny);
let world = random_... | true |
865919115924ea5f1213a10e7c6a50c243d8c2a8 | Rust | Cheshulko/Algorithms | /exercism.io/rust/luhn/src/lib.rs | UTF-8 | 1,612 | 3.28125 | 3 | [] | no_license | /// Check a Luhn checksum.
pub fn is_valid(code: &str) -> bool {
let ans = code
.chars()
.all(|c| c.is_ascii_digit() || c.is_whitespace())
.then(|| {
let filtred = code
.chars()
.rev()
.filter(|c| !c.is_whitespace())
... | true |
559fad04837b8185fbcb249dec155b8eb79b3a0c | Rust | Pedrexus/lambda.strategy | /src/sources/yahoo/period.rs | UTF-8 | 6,939 | 3.328125 | 3 | [] | no_license | use chrono::{DateTime, Duration, Utc};
use std::collections::HashMap;
use std::fmt;
use std::str::FromStr;
/// An interval use when requesting periods of quote information.
/// ChartRange = start/end
/// a ChartRange of `5d` means data will range from **5 days ago** until **now**
#[allow(non_camel_case_types)]
#[deriv... | true |
cd306cc75ff29073bd4601e0d5acade778b9a34c | Rust | hooops/crypto-crawler-rs | /crypto-ws-client/src/clients/ws_client_internal.rs | UTF-8 | 21,955 | 2.796875 | 3 | [
"Apache-2.0"
] | permissive | use super::utils::connect_with_retry;
use std::{
collections::HashSet,
io::prelude::*,
sync::{
atomic::{AtomicBool, AtomicIsize, Ordering},
mpsc::Sender,
Mutex,
},
time::{Duration, Instant},
};
use flate2::read::{DeflateDecoder, GzDecoder};
use log::*;
use tungstenite::{
... | true |
f990f556c88cea457be5c259c85a0b0d4f76e00c | Rust | y-yagi/til | /leetcode/find-the-difference/rust/src/lib.rs | UTF-8 | 752 | 3.296875 | 3 | [] | no_license | #[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
assert_eq!(Solution::find_the_difference("abcd".to_string(), "abcde".to_string()), 'e');
assert_eq!(Solution::find_the_difference("".to_string(), "y".to_string()), 'y');
}
}
struct Solution {}
use std::collections::HashMap... | true |
72aeb9a2b3ed9af85ce9d5a43399bf2c85faeeeb | Rust | krasnobaev/rust | /src/hackerrank/src/30daysofcode/1-data-types.rs | UTF-8 | 672 | 3.09375 | 3 | [] | no_license | use std::io::{self, BufRead};
fn main() {
let stdin = io::stdin();
let mut int_num = String::new();
stdin.read_line(&mut int_num).expect("failed to read stdin");
let int_num: i32 = int_num.trim().parse().expect("invalid input");
let mut double_num = String::new();
stdin.read_line(&mut double_num).expect(... | true |
e544e687611a5a9e20185c5e9a4c1e562570f23b | Rust | omerbenamram/evtx | /src/binxml/name.rs | UTF-8 | 3,006 | 2.796875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::err::DeserializationResult as Result;
use crate::ChunkOffset;
pub use byteorder::{LittleEndian, ReadBytesExt};
use crate::utils::read_len_prefixed_utf16_string;
use std::{
fmt::Formatter,
io::{Cursor, Seek, SeekFrom},
};
use quick_xml::events::{BytesEnd, BytesStart};
use std::fmt;
#[derive(Debug... | true |
9f4b0224922f2ad28c694258b5871030a8216b03 | Rust | IThawk/rust-project | /rust-master/src/librustc_data_structures/graph/vec_graph/tests.rs | UTF-8 | 1,027 | 3.375 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | use super::*;
fn create_graph() -> VecGraph<usize> {
// Create a simple graph
//
// 5
// |
// V
// 0 --> 1 --> 2
// |
// v
// 3 --> 4
//
// 6
VecGraph::new(
7,
vec![
(0, 1),
... | true |
f6fc141693473744d356c00e1fa90606b3ab368b | Rust | rfdonnelly/advent-of-code | /2021/src/d06.rs | UTF-8 | 1,788 | 3.53125 | 4 | [] | no_license | use crate::input;
const DAY: usize = 6;
pub fn run() -> String {
let input = input(DAY);
let mut output = String::new();
let time = std::time::Instant::now();
output += &format!("d{:02}p1: {} in {:?}\n", DAY, p1(&input), time.elapsed());
let time = std::time::Instant::now();
output += &format!... | true |
54058f17e22afe96c1e4e49895f2aa4e68561dd7 | Rust | pnkfelix/pgy | /src/gll/codegen.rs | UTF-8 | 13,888 | 2.984375 | 3 | [] | no_license | use grammar::{Grammar, NontermName, Rule, Sym, TermName};
pub fn codegen<B:BackendText>(back: &mut B) -> String where
// IMO these should not be necessary, see Rust issue #29143
B::Block: RenderIndent
{
let mut s = String::new();
s = s + &back.prefix();
let indent = back.rule_indent_preference();
... | true |
98eae0608bce340dbbe9e3964aac9a3c2374d2bb | Rust | radu-matei/wal | /src/compiler.rs | UTF-8 | 557 | 2.765625 | 3 | [] | no_license | use crate::{ast::{Node}, code::Instructions, object::Object};
#[derive(Default)]
pub struct Compiler {
pub instructions: Instructions,
pub constants: Vec<Object>,
}
impl Compiler {
pub fn new() -> Self {
let instructions = Instructions { stream: Vec::new() };
let constants: Vec<Object> = V... | true |
d06a09345b657bb366a5ec4d2d8a103999017392 | Rust | shorii/asset-rs | /asset/src/dir.rs | UTF-8 | 1,859 | 2.890625 | 3 | [] | no_license | use super::file::AssetFile;
use anyhow::{anyhow, bail, Result};
use std::path::Path;
use uuid::Uuid;
#[derive(Debug, Clone)]
pub struct AssetDir<'a> {
pub id: Uuid,
pub name: String,
pub dirs: Vec<AssetDir<'a>>,
pub files: Vec<AssetFile<'a>>,
}
impl<'a> AssetDir<'a> {
pub fn name(&self) -> String ... | true |
81bf15561df7ec7c3f8f35794d68eb9ea3461221 | Rust | chiliseed/cli | /src/api_client/errors.rs | UTF-8 | 1,026 | 2.71875 | 3 | [] | no_license | use std::error::Error;
use std::fmt;
use reqwest;
use url::ParseError;
#[derive(Debug)]
pub enum ApiClientError {
HTTPRequestError(String),
HTTPTimeoutError(reqwest::Error),
DeSerializerError(String),
URLParseError(ParseError),
}
impl Error for ApiClientError {}
impl From<ParseError> for ApiClientEr... | true |
3e713c40cb043d7ee29c5ff31451b5fa89b6f6c9 | Rust | pandaman64/succ_nix | /src/span.rs | UTF-8 | 335 | 2.625 | 3 | [] | no_license | #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Span {
pub start: usize,
pub end: usize,
}
impl From<rnix::TextRange> for Span {
fn from(range: rnix::TextRange) -> Self {
Span {
start: range.start().into(),
end: range.end().into(),
... | true |
ca40d6acce037045acbb44b250fd4a57ad4a34f1 | Rust | rob-brown/AdventOfCode2019 | /src/aoc/day19.rs | UTF-8 | 1,109 | 3.0625 | 3 | [
"MIT"
] | permissive | use super::assert::*;
use super::intcode::Machine;
pub fn in_beam(point: (i64, i64), machine: &Machine) -> bool {
let mut machine = Machine::init(&machine.positions);
machine.run(vec![point.1, point.0]);
machine.values.pop_front() == Some(1)
}
pub fn solve() {
let machine = Machine::from_file("input/... | true |
72549ef81a1e7543442aebaba23306d10a4ee397 | Rust | w3f-grants-archive/polpatrol | /src/generation/balancesmodule.rs | UTF-8 | 5,748 | 2.515625 | 3 | [] | no_license | // ------ SRML BALANCES MODULE ------
use substrate_sr_sudo::Call as SudoCall;
use polkadot_runtime::{BalancesCall, Call};
use super::*;
pub fn craft_extrinsics() -> Vec<PreparedEx> {
let mut exs = Vec::new();
/*
Extrinsic Description
Module: Balances
Function: set_balances
Type: Requires r... | true |
13beee34066a3629ba27965792a0ba80e94fe701 | Rust | femnad/meh | /src/main.rs | UTF-8 | 7,322 | 2.59375 | 3 | [] | no_license | #[macro_use]
extern crate clap;
extern crate dirs;
extern crate serde;
use std::process::Command;
use std::io::prelude::*;
use std::fs::File;
use clap::{App, Arg, SubCommand, AppSettings};
use serde::Deserialize;
mod confluence;
mod ops;
const DEFAULT_PROFILE: &str = "default";
const PROFILE_FILE_SUFFIX: &str = "me... | true |
28c5eef42fd381f4a204fdbf98c41491141f474b | Rust | balabit/syslog-ng-rust-modules | /actiondb-parser/src/bin/parse.rs | UTF-8 | 1,383 | 2.84375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | use std::fs::File;
use std::io::{BufReader, BufRead, Error, ErrorKind, BufWriter, Write};
use actiondb::Matcher;
use actiondb::matcher::{PatternLoader, MatcherSuite};
pub fn parse<MS: MatcherSuite>(pattern_file_path: &str,
input_file_path: &str,
output_file_path: &str)
-> Result<... | true |
cb0c946bda3953c4bafba58aad1cb02dfd6f9072 | Rust | KlaraOppenheimerSchule/Grundlagen-Programmierung_Rust | /04_Vertiefung_Objektorientierung/02_Strukturierung_Programmcode/SR_02_Hotellzimmerverwaltung/src/structure.rs | UTF-8 | 8,361 | 2.9375 | 3 | [] | no_license | use std::fs::File;
use std::io::prelude::*;
use serde::Serialize;
use serde::Deserialize;
use serde_json::{Result, Value};
use serde_json as json;
use colored::*;
use std::convert::TryInto;
use std::io::stdout;
use std::io::stdin;
use sha2::digest::DynDigest;
use sha2::Digest;
use std::borrow::{Borrow, BorrowMut};
... | true |
99b761ea71ec7c70b0c2383c1260173a203777d0 | Rust | leroycep/exercism-solutions | /rust/raindrops/src/lib.rs | UTF-8 | 438 | 2.890625 | 3 | [] | no_license | use std::fmt::Write;
pub fn raindrops(n: u32) -> String {
let mut s = String::new();
let pling = n % 3 == 0;
let plang = n % 5 == 0;
let plong = n % 7 == 0;
if pling {
write!(s, "Pling").unwrap();
}
if plang {
write!(s, "Plang").unwrap();
}
if plong {
write!... | true |
7762b6fabaf2e7bcfd5da8ed6d7de766a3463ae2 | Rust | rayon-rs/rayon | /rayon-demo/src/tsp/solver.rs | UTF-8 | 3,339 | 3.078125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::collections::BinaryHeap;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Arc, Mutex};
use std::usize;
use super::graph::{Graph, Node};
use super::step;
use super::tour::TourPrefix;
use super::weight::Weight;
/// Shared context
pub struct SolverCx<'s> {
graph: &'s Graph,
seq_threshold:... | true |
a4b0239e28148c6cb5f173dfaec75b5de0a4010d | Rust | parkovski/scifiweb | /model/src/lib.rs | UTF-8 | 2,538 | 2.75 | 3 | [] | no_license | #![allow(dead_code)]
#![cfg_attr(not(feature = "cargo-clippy"), allow(unknown_lints))]
#![feature(conservative_impl_trait, box_syntax)]
extern crate either;
extern crate futures;
extern crate serde;
extern crate serde_json;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate log;
extern crate scifi_util ... | true |
5cd597401566267d2f2f24700469ef2ee354010b | Rust | ElLibertador/remittance | /src/msg.rs | UTF-8 | 4,545 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use cosmwasm_std::{Addr, Api, Coin, StdResult};
use cw20::{Cw20Coin, Cw20ReceiveMsg};
use crate::state::{TrustMetrics};
#[derive(Serialize, Deserialize, JsonSchema)]
pub struct InstantiateMsg {}
// List of all possible execution methods
#[derive(Serial... | true |
3a57af5ed3ffab92d8bda4f9ffe8b6f742b67283 | Rust | scotow/advent-of-code | /2015/src/bin/day_17.rs | UTF-8 | 711 | 2.625 | 3 | [] | no_license | advent_of_code_2015::main!();
fn generator(input: &str) -> Vec<u16> {
input.lines().map(|l| l.parse().unwrap()).collect()
}
fn part_1(containers: Vec<u16>) -> usize {
matching(containers).count()
}
fn part_2(containers: Vec<u16>) -> usize {
let mut mapping = HashMap::new();
matching(containers)
... | true |
7ba40357e2c50a13c7443634928d47b5b1a42d9d | Rust | ericgroom/randtime | /src/time_service/time_gen.rs | UTF-8 | 1,362 | 3.3125 | 3 | [] | no_license | extern crate chrono;
extern crate rand;
use chrono::prelude::*;
use rand::prelude::*;
use serde::Serialize;
use std::fmt::Debug;
#[derive(Debug, Serialize)]
pub struct TimeInfo {
pub random_time: DateTime<Utc>,
pub next_generation_time: DateTime<Utc>,
}
impl TimeInfo {
pub fn new() -> TimeInfo {
... | true |
3825cae718886d85e22c90baca14f34cd5a97c51 | Rust | sprajagopal/rusting | /wysgy_core/src/wysgy.rs | UTF-8 | 2,146 | 2.65625 | 3 | [] | no_license | use crate::converter::Converter;
use crate::errors::WysgyResult;
use crate::files::{CONFIG_JSON_CONTENTS, GV_TEMPLATE_CONTENTS};
use crate::node::Node;
use crate::rel::Rel;
use glob::glob;
use prettytable::Table;
use serde_json::{json, Value};
use std::cmp::max;
use std::error;
use std::fs;
use std::io::{BufRead, Error... | true |
7f70906e4c6d0c529c564849416fcee2e906eadb | Rust | frankier/softcomputingforsoftpeople | /proj/src/corpus.rs | UTF-8 | 2,411 | 2.921875 | 3 | [] | no_license | use std::collections::{BTreeMap, BTreeSet};
use std::collections::btree_map::Entry;
use indexmap::IndexSet;
pub type WordId = usize;
#[derive(Serialize, Deserialize, Debug)]
pub struct WordInfo {
pub string: String,
pub freq: u64,
}
#[derive(Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Copy, Clon... | true |
5c7ca58bf65bd50d945add0b811332d3b15b5e0a | Rust | yongkyuns/manim-rs | /src/object/text.rs | UTF-8 | 5,910 | 2.59375 | 3 | [
"MIT"
] | permissive | use crate::animation::PathCompletion;
use crate::appearance::{GetOpacity, Opacity, SetOpacity};
use crate::arena::Object;
use crate::consts::*;
use crate::draw::Draw;
use crate::geom;
use crate::geom::{dimension, Dimension, GetDimension, SetDimension};
use crate::geom::{point_at, GetOrientation, GetPosition, SetOrienta... | true |
49afb73b9ea9e7198ddae7688d80ebd7d6bdcc38 | Rust | baszalmstra/omniverse | /src/culling.rs | UTF-8 | 1,023 | 2.84375 | 3 | [] | no_license | use nalgebra::{Point3, Scalar};
use ncollide::bounding_volume::AABB3;
#[derive(Copy, Clone, PartialEq)]
pub enum Containment {
Outside,
Inside,
Intersects,
}
pub trait Classify<T> {
fn classify(&self, shape: &T) -> Containment;
fn intersects(&self, shape: &T) -> bool {
self.classify(shape)... | true |
d6f6e038a3bb4be89dd310ee272583aca58ec331 | Rust | xe6/rust_playground | /src/loops.rs | UTF-8 | 963 | 4.34375 | 4 | [] | no_license | // Loops - Used to iterate until a condition is met
pub fn run() {
let mut count0 = 0;
let mut count1 = 0;
// Infinite loop
println!("Infinite loop (with break condition)");
loop {
count0 += 1;
println!("Number: {}", count0);
if count0 == 20 { break };
}
// While ... | true |
8f9c9e230e9306543158264566a03755f808b066 | Rust | pact-foundation/pact-reference | /compatibility-suite/tests/v4_steps/http_matching.rs | UTF-8 | 7,942 | 2.53125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::fs::File;
use std::io::BufReader;
use anyhow::anyhow;
use cucumber::gherkin::Step;
use cucumber::{given, then, when};
use maplit::hashmap;
use pact_models::interaction::Interaction;
use pact_models::matchingrules::matchers_from_json;
use pact_models::pact::Pact;
use pact_models::v4::http_parts::{HttpRequest, H... | true |
703d079b65cdc7e87dbeb911f458426ae2cc6c32 | Rust | CmdrMoozy/euler | /src/bin/00050.rs | UTF-8 | 2,623 | 3.046875 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2013 Axel Rasmussen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in w... | true |
b0dbf39ba3f2b2f401749b9c8b05c1e6c19cfe49 | Rust | jeffparsons/ncollide | /src/partitioning/bvtt_visitor.rs | UTF-8 | 532 | 2.859375 | 3 | [
"BSD-2-Clause"
] | permissive | /// Visitor for the Bounding Volume Traversal Tree.
// FIXME: make this more generic using <B1, BV1, B2, BV2> ?
pub trait BVTTVisitor<B, BV> {
/// Visit two internal nodes.
fn visit_internal_internal(&mut self, &BV, &BV) -> bool;
/// Visit two leaves.
fn visit_leaf_leaf(&mut self, &B, &BV, &B, &BV);
... | true |
1b781c0da1bd01fc0622deb5f5cac12640269cf1 | Rust | ltruchot/haiku-generator | /src/string.rs | UTF-8 | 1,143 | 2.96875 | 3 | [] | no_license | // IMPORTS
// externals
use unicode_segmentation::UnicodeSegmentation;
// EXPORTS
pub fn take_last_grapheme(word: &str) -> String {
let s = String::from(word);
// check last
let last = s.graphemes(true).last();
String::from(match last {
Some(letter) => letter,
None => "",
})
}
pub ... | true |
6f964546a17019e071adbcd337d4f391caaec1eb | Rust | eulegang/er-rusted | /src/ui/tui/mode/key_seq/mod.rs | UTF-8 | 2,005 | 2.546875 | 3 | [] | no_license | use crate::ui::tui::motion::{Idemp, Motion, SealedMotion, Search};
mod parse;
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct KeySeq {
pub num: usize,
pub action: KSAction,
}
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum KeySeqErr {
Failed,
Insufficient,
}
#[derive(Debug, PartialEq, Eq, Clone)]
... | true |
0794a4f0ff3fc19095045927563de13233b48ded | Rust | teliosdev/kvm | /src/core/mod.rs | UTF-8 | 3,729 | 2.625 | 3 | [] | no_license | use super::error::*;
use kvm_sys as kvm;
use std::fs::File;
use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
mod data;
mod exit;
mod state;
pub use self::data::{Data, DataMut};
pub use self::exit::{Exit, ExitMut};
pub use self::state::State;
#[derive(Debug)]
pub struct Core(pub(crate) File, *mut kvm::R... | true |
6e19939b4ee60c87cf1c0d959c2eef7c6a632fa9 | Rust | samfatoks/util-server | /src/model/command.rs | UTF-8 | 985 | 2.875 | 3 | [
"MIT"
] | permissive | use super::{CodecAlgorithm, HashingAlgorithm, RndType, ChecksumAlgorithm};
use crate::error::Error;
#[derive(Debug, PartialEq, Clone)]
pub enum Command {
RND(RndType),
HASH(HashingAlgorithm),
ENCODE(CodecAlgorithm),
DECODE(CodecAlgorithm),
CHECKSUM(ChecksumAlgorithm)
}
impl std::str::FromStr for C... | true |
b0227eec392bd3eaaf62b19a4abf56f9bbdf9c66 | Rust | smoltcp-rs/smoltcp | /src/iface/rpl/trickle.rs | UTF-8 | 9,407 | 2.6875 | 3 | [
"BSD-3-Clause",
"0BSD",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Implementation of the Trickle timer defined in [RFC 6206]. The algorithm allows node in a lossy
//! shared medium to exchange information in a highly robust, energy efficient, simple, and
//! scalable manner. Dynamicaly adjusting transmission windows allows Trickle to spread new
//! information fast while sending o... | true |
a21b617647b6b2462e6b7653b89e1de68d870464 | Rust | mmstick/advent-of-code-solutions | /05/second/main.rs | UTF-8 | 816 | 3.390625 | 3 | [
"MIT"
] | permissive | // 0.018s on A4-5000 (1.5 GHz)
fn main() {
let input = include_str!("input.txt");
let nice_count = input.lines().filter(|string| is_nice(string)).count();
println!("{}", nice_count);
}
/// Returns true if the string is nice
fn is_nice(x: &str) -> bool {
let mut double_char = false;
let mut double_p... | true |
9086323491a958fafe530a223e88860801a95187 | Rust | mkotsollaris/DharmaDB | /tests/basic_compaction_test.rs | UTF-8 | 6,827 | 2.546875 | 3 | [
"MIT"
] | permissive | use crate::common::test_key::TestKey;
use crate::common::test_value::TestValue;
use crate::common::{cleanup_paths, get_test_data, get_test_data_in_range};
use dharmadb::options::DharmaOpts;
use dharmadb::storage::block::Value;
use dharmadb::storage::compaction::basic::{BasicCompaction, BasicCompactionOpts};
use dharmad... | true |
e0814369832f79e72c1d363dd73c457b2fc3375d | Rust | agausmann/NewtonFractal | /src/config.rs | UTF-8 | 2,440 | 3.203125 | 3 | [
"0BSD"
] | permissive | use glam::{Vec2, Vec4};
pub struct Config {
pub num_iterations: u32,
pub roots: Vec<RootConfig>,
pub camera: CameraConfig,
}
impl Config {
pub fn apply(&mut self, event: &ConfigChangeEvent) {
match event {
&ConfigChangeEvent::NumIterations(v) => {
self.num_iteration... | true |
49a5b6bf58bcde7d179dbc03bdb49ccdbdd1232e | Rust | Devolutions/siquery-rs | /siquery/src/windows/wmi_printers.rs | UTF-8 | 6,782 | 2.859375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::process::Command;
use std::borrow::Borrow;
use crate::tables::{WmiPrinters,WmiPrintersIface};
use crate::utils;
pub struct Reader {}
impl WmiPrintersIface for Reader {
fn get_wmi_printers_info(&self) -> Option<String> {
let output = Command::new("wmic")
.args(&["printer",
... | true |
324649044fc8c747cba5bc2ff962b45fb9afe23c | Rust | SpectralSequences/sseq | /chart/chart/display_backend/src/shader/attributes.rs | UTF-8 | 6,319 | 2.828125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::convert::{TryInto, TryFrom};
use web_sys::{WebGl2RenderingContext, WebGlVertexArrayObject, WebGlBuffer, WebGlProgram};
use wasm_bindgen::JsValue;
use crate::webgl_wrapper::WebGlWrapper;
#[derive(Copy, Clone, Debug)]
pub enum Type {
F32,
U32,
I16, U16,
U8,
}
impl Type {
fn size(self) -> ... | true |
8c27f3ab366ee1a39a2587f40d0afeecb162ecc4 | Rust | LanceEa/pgx | /pgx/src/datum/array.rs | UTF-8 | 11,316 | 2.640625 | 3 | [
"MIT"
] | permissive | // Copyright 2020 ZomboDB, LLC <zombodb@gmail.com>. All rights reserved. Use of this source code is
// governed by the MIT license that can be found in the LICENSE file.
use crate::{pg_sys, void_mut_ptr, FromDatum, IntoDatum, PgMemoryContexts};
use serde::Serializer;
use std::marker::PhantomData;
pub type VariadicArr... | true |
e95ee7e07eca98ea669c54bc0394dc6addb0050b | Rust | zsiciarz/euler.rs | /src/solutions/problem20.rs | UTF-8 | 609 | 2.6875 | 3 | [] | no_license | use num::{BigInt, One, Zero};
use num::traits::{FromPrimitive, ToPrimitive};
use super::{SolutionResult, SolutionError};
use super::common::digits;
pub fn solution() -> SolutionResult {
let one: BigInt = One::one();
let zero: BigInt = Zero::zero();
let fac100 = (1i64..101)
.map(|x| ->... | true |
47dfbe9cf37159ef21a8737b09ee6c9edb8204c7 | Rust | codesections/dlarm | /src/cli.rs | UTF-8 | 3,877 | 2.859375 | 3 | [] | no_license | use clap::{crate_authors, crate_version, App, Arg, ArgGroup, SubCommand};
pub fn build_cli() -> App<'static, 'static> {
let CliText {
message,
set,
off,
app,
snooze,
} = CliText::new();
App::new(app.name)
.version(crate_version!())
.author(crate_author... | true |
d19d83cff095fe0e27966a91eb1312f54122f31f | Rust | nannany/rust_practice | /iterator/src/main.rs | UTF-8 | 239 | 3.15625 | 3 | [] | no_license | fn main() {
let mut vec: Vec<usize> = Vec::<usize>::new();
vec.push(1);
vec.push(2);
vec.push(3);
vec.push(5);
let mut iter = vec.iter();
while let Some(ele) = iter.next() {
println!("{}", ele);
}
}
| true |
df5fac54f59cce038e7be8acd47260c2463267c5 | Rust | OddBloke/RustPython | /parser/src/lexer.rs | UTF-8 | 32,883 | 3.09375 | 3 | [
"MIT"
] | permissive | pub use super::token::Tok;
use std::collections::HashMap;
use std::iter::FromIterator;
use std::str::CharIndices;
use std::str::FromStr;
pub struct Lexer<'input> {
chars: CharIndices<'input>,
at_begin_of_line: bool,
nesting: usize, // Amount of parenthesis
indentation_stack: Vec<usize>,
pending: Ve... | true |
9df4f4103a4a0ddf3ec5351a11be68331d7e591c | Rust | fredmorcos/attic | /Coding/AoC2021/rustic-mob-meetup/rustic-mob-day04/src/main.rs | UTF-8 | 1,773 | 2.9375 | 3 | [
"MIT",
"Unlicense"
] | permissive | use regex::Regex;
use std::{error::Error, fmt, fs};
use walkdir::WalkDir;
mod day01;
mod day02;
mod day03;
mod day04;
static FUNCS: &[fn(&str)] = &[day01::run, day02::run, day03::run, day04::run];
struct MainErr(String);
impl MainErr {
fn with_message(msg: String) -> Result<(), Box<dyn Error>> {
Err(Box::new(... | true |
ab9d08f1a5d66bcaa21bfce2701d9e00c4f80bf8 | Rust | severen/practice | /exercism/rust/bob/src/lib.rs | UTF-8 | 545 | 3.359375 | 3 | [
"Unlicense"
] | permissive | fn is_yelling(message: &str) -> bool {
// We check for an alphabetic character so that a string like ":)" is not
// accepted.
message.to_uppercase() == message && message.contains(char::is_alphabetic)
}
pub fn reply(message: &str) -> &str {
match message.trim() {
m if is_yelling(m) && m.ends_wi... | true |
0c2ec36fd67fc30d8b7c21b1c0d219820a8a1c2b | Rust | vigna/webgraph-rs | /src/algorithms/bfs_order.rs | UTF-8 | 1,245 | 2.796875 | 3 | [
"Apache-2.0",
"LGPL-2.1-only"
] | permissive | use crate::traits::RandomAccessGraph;
use bitvec::prelude::*;
use dsi_progress_logger::ProgressLogger;
use std::collections::VecDeque;
/// Visit the graph in BFS order and return a vector with the order in which the
/// nodes were visited
pub fn bfs_order<G: RandomAccessGraph>(graph: &G) -> Vec<usize> {
let num_no... | true |
f93e45084c29483578220f2a389adb21ff6a602b | Rust | jeromebenois/couchbase-lite-c-rs | /couchbase-lite-c/benches/bench.rs | UTF-8 | 1,564 | 2.796875 | 3 | [
"MIT"
] | permissive | #[macro_use]
extern crate criterion;
use couchbase_lite_c::{Database, Document};
use criterion::Criterion;
use serde::{Deserialize, Serialize};
use std::fs;
fn test_dir() -> String {
let dir = "/tmp/benchdb".to_string();
match fs::create_dir_all(dir.clone()) {
Ok(_) => {}
Err(e) => panic!("Can... | true |
31fc544f26f7147d3ebc7efdb309c4322c1fe2e4 | Rust | hakua-doublemoon/AtCorder | /abc164_c/src/main.rs | UTF-8 | 3,182 | 3.4375 | 3 | [
"MIT"
] | permissive |
const NUM_OF_AB :usize = 26;
const A_INDEX :usize = 97;
struct Category {
//depth :u32,
children :Vec<Category>,
list :Vec<String>,
active_bmp :u32,
}
impl Category {
//fn new(depth :u32) -> Category
fn new() -> Category
{
Category {
//depth: depth,
... | true |
7bf35ecf7f9519387f26cab0aac5461eae898896 | Rust | EmbarkStudios/rust-gpu | /crates/rustc_codegen_spirv/src/linker/zombies.rs | UTF-8 | 17,301 | 2.59375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! See documentation on `CodegenCx::zombie` for a description of the zombie system.
use super::{get_name, get_names};
use crate::custom_decorations::{CustomDecoration, SpanRegenerator, ZombieDecoration};
use crate::custom_insts::{self, CustomOp};
use rspirv::dr::{Instruction, Module, Operand};
use rspirv::spirv::{Op,... | true |
d316c90090d6266e7670d786e009cc28f12474f2 | Rust | noobdevth/hello-rust | /src/part-1/temperature.rs | UTF-8 | 1,287 | 4.03125 | 4 | [] | no_license | use std::io;
const CELSIUS: &'static str = "C";
const FAHRENHEIT: &'static str = "F";
// C = 5/9 (F-32)
fn to_celsius(temp: f32) -> f32 {
((temp - 32.0) * 5.0) / 9.0
}
// F = 1.8 C + 32
fn to_fahrenheit(temp: f32) -> f32 {
(temp * 1.8) + 32.0
}
fn input(message: &'static str) -> String {
let mut input = Strin... | true |
918534344746881c9f7e1f157959c4c17627aabc | Rust | ngi-nix/reowolf | /src/protocol/parser/tokens.rs | UTF-8 | 11,417 | 3.5 | 4 | [
"MIT"
] | permissive | use crate::protocol::input_source::{
InputPosition as InputPosition,
InputSpan
};
/// Represents a particular kind of token. Some tokens represent
/// variable-character tokens. Such a token is always followed by a
/// `TokenKind::SpanEnd` token.
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pu... | true |
96bca0fb716558d8e6323613efb7c56445f455ae | Rust | DougAnderson444/solpin | /src/dapplib/programs/src/state.rs | UTF-8 | 1,230 | 2.984375 | 3 | [] | no_license | use solana_program::{
program_error::ProgramError,
program_pack::{Pack, Sealed},
};
use borsh::{BorshDeserialize, BorshSerialize};
// use std::mem;
// pub trait Serdes: Sized + BorshSerialize + BorshDeserialize {
// fn pack(&self, dst: &mut [u8]) {
// let encoded = self.try_to_vec().unwrap();
// dst[..enc... | true |
1308e4224c0f1ee35c7d1a242bd08118d73e7fea | Rust | Daenecompass/cognitive-services-speech-sdk-rs | /tests/integration_test.rs | UTF-8 | 3,641 | 2.546875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use cognitive_services_speech_sdk_rs as msspeech;
use log::*;
use std::env;
#[tokio::test]
// ignored so that these tests are not run by CI during build without subscription key
#[ignore]
async fn speech_to_text() {
let filename = env::var("WAVFILENAME").unwrap();
let audio_config = msspeech::audio::AudioConfi... | true |
8f9655be843ca612690747c5909d37ae75d09403 | Rust | Jimskapt/rust-book-fr | /FRENCH/listings/ch20-web-server/listing-20-13/src/lib.rs | UTF-8 | 579 | 2.9375 | 3 | [
"Apache-2.0",
"MIT",
"Unlicense",
"BSD-3-Clause",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"LicenseRef-scancode-other-permissive",
"NCSA"
] | permissive | pub struct GroupeTaches;
// ANCHOR: here
impl GroupeTaches {
/// Crée un nouveau GroupeTaches.
///
/// La taille est le nom de tâches présentes dans le groupe.
///
/// # Panics
///
/// La fonction `new` devrait paniquer si la taille vaut zéro.
pub fn new(taille: usize) -> GroupeTaches {... | true |
99ecbb7d358bde7ee9c6211f6cc97d3ee53702f0 | Rust | rust-lang/rust-bindgen | /bindgen/codegen/postprocessing/merge_extern_blocks.rs | UTF-8 | 2,239 | 2.859375 | 3 | [
"BSD-3-Clause"
] | permissive | use syn::{
visit_mut::{visit_file_mut, visit_item_mod_mut, VisitMut},
File, Item, ItemForeignMod, ItemMod,
};
pub(super) fn merge_extern_blocks(file: &mut File) {
Visitor.visit_file_mut(file)
}
struct Visitor;
impl VisitMut for Visitor {
fn visit_file_mut(&mut self, file: &mut File) {
visit_i... | true |
78852881de1f8caa540452a6cc2278b8bd15aff5 | Rust | arcnmx/stack-rs | /tests/small_vec.rs | UTF-8 | 2,739 | 2.796875 | 3 | [
"MIT"
] | permissive | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use stack::{ArrayVec, SmallVec, Vector};
#[test]
pub fn test_inline() {
let mut v = SmallVec::<[String; 16]>:... | true |
07f9b6e2241902cd5d0b99e2dc0e93df7d54e006 | Rust | matthewelse/advent-of-code-2017 | /day17/src/main.rs | UTF-8 | 966 | 3.359375 | 3 | [] | no_license | fn state(buffer: &Vec<usize>, position: usize) -> String {
let mut out: Vec<String> = vec![];
for i in 0..buffer.len() {
if i == position {
out.push(format!("({})", buffer[i]));
} else {
out.push(buffer[i].to_string());
}
}
out.join(" ")
}
fn part2(step... | true |
0b049facc694e59516c2b4375060d3acfa3579ee | Rust | ganita/akriti-core | /core/src/props/property_modifier.rs | UTF-8 | 1,156 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | /*
* Copyright 2017 Sreejith Krishnan R
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed... | true |
6380ab2370d6ddb3c98d165b827412638131f686 | Rust | arizuk/programming-contest-solutions | /atcoder/ARC075/C/main.rs | UTF-8 | 4,480 | 2.953125 | 3 | [] | no_license | #[allow(unused_macros)]
macro_rules! input {
(source = $s:expr, $($r:tt)*) => {
let mut iter = $s.split_whitespace();
let mut next = || { iter.next().unwrap() };
input_inner!{next, $($r)*}
};
($($r:tt)*) => {
let stdin = std::io::stdin();
let mut bytes = std::io::Read... | true |
37d2f809bc33e966fcee6e44de99fc5b84116969 | Rust | clayrab/saito-rust | /build.rs | UTF-8 | 1,362 | 2.84375 | 3 | [] | permissive | use std::{env, fs::File, io::Write, path::Path};
// Please do not change this value, it will cause tests to run very long
// If we are doing a production build, this value can be set via environmental variable
// as described below
const EPOCH_LENGTH: i64 = 1000;
fn main() {
write_epoch_length_to_constants();
}
... | true |
ec25b60e5c1c8169812361e6af13e2e3117070e9 | Rust | YieldLabs/simple.nn | /simple_nn/src/nn.rs | UTF-8 | 740 | 3.140625 | 3 | [
"MIT"
] | permissive | use super::tensor::Tensor1D;
use super::shared::Layer;
#[derive(Debug)]
pub struct Linear {
weight: Tensor1D,
bias: Tensor1D
}
impl Linear {
pub fn new(size: (usize, usize)) -> Self {
Self {
weight: Tensor1D::uniform(size.0),
bias: Tensor1D::ones(1)
}
}
}
impl ... | true |
feb545b7a99cdbfc6f9d314f989417ffadc51ff9 | Rust | ahoetker/advent-of-code-2020 | /day1/src/main.rs | UTF-8 | 876 | 3.296875 | 3 | [] | no_license | use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
fn read_input() -> std::io::Result<Vec<u32>> {
let input = File::open("input.txt")?;
let reader = BufReader::new(input);
Ok(reader
.lines()
.map(|line| line.unwrap().parse::<u32>().unwrap())
.collect())
}
fn main(... | true |
732926492da0363d1d076a3d53a3d03f53103a64 | Rust | 10allday-kai/api-daemon | /services/procmanager/src/android_worker.rs | UTF-8 | 4,481 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | // Android specific implementation of GenerationWorker
use crate::cgroups::{CGroupError, GenerationWorker};
use log::{debug, error};
use std::collections::HashSet;
use std::fs::{read_dir, DirEntry, File, OpenOptions};
use std::io::{Error, Read, Write};
use std::path::Path;
const CGROUP_MEM: &str = "/dev/memcg/b2g";
... | true |
3f2a913fcc5730889860d73258a200bd1fc3937c | Rust | kiskoza/30days-of-rust | /day17/src/calculator.rs | UTF-8 | 213 | 3.25 | 3 | [] | no_license | pub struct Calculator {
}
impl Calculator {
pub fn power(&self, n: i32, p: i32) -> Result<i32, String> {
if n < 0 || p < 0 {
Err("Asd".to_string())
} else {
Ok(n.pow(p as u32))
}
}
}
| true |
3da5e37aef8fd6aa9ab8e2c2c2f4cce8066e91cd | Rust | danslocombe/dns-spoof-rust | /src/main.rs | UTF-8 | 9,154 | 2.640625 | 3 | [] | no_license | extern crate argparse;
extern crate pnet;
use argparse::{ArgumentParser, Store, StoreTrue};
use pnet::datalink::{self, NetworkInterface};
use pnet::datalink::Channel::Ethernet;
use pnet::packet::{MutablePacket, Packet};
use pnet::packet::ethernet::{MutableEthernetPacket, EthernetPacket, EtherType};
use pnet::packet::... | true |
7b0708bf127313179461354a51c54647ecb390ed | Rust | hwchen/lemurdb | /src/executor/selection.rs | UTF-8 | 502 | 3.046875 | 3 | [] | no_license | use super::DbIterator;
use super::tuple::Tuple;
#[derive(Debug, Clone)]
pub struct Selection<I,P> {
pub input: I,
pub predicate: P,
}
impl <I: DbIterator, P> DbIterator for Selection<I,P>
where P: FnMut(&Tuple) -> bool,
{
fn next(&mut self) -> Option<Tuple> {
while let Some(x) = self.input.nex... | true |
d75592f11b5808f99181780aa5d7b4e0748441f4 | Rust | ChaiTRex/advent-of-code-2019 | /rust/day14/src/main.rs | UTF-8 | 7,112 | 2.96875 | 3 | [
"MIT"
] | permissive | use std::{
collections::{HashMap, HashSet},
fs::File,
hash::Hash,
io::{BufRead, BufReader},
str::FromStr,
};
fn main() {
let recipes = {
let mut recipes = HashMap::new();
BufReader::new(File::open("../14.txt").unwrap())
.lines()
.for_each(|line| {
... | true |
ff7889578c08f290e7318b3774f64d8ffa65adb6 | Rust | shekohex/rsdiff | /src/lib.rs | UTF-8 | 7,993 | 3.359375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #![deny(unsafe_code)]
//! ## rsdiff(1).
//!
//! A simple implementation of [`rdiff(1)`](https://linux.die.net/man/1/rdiff).
//!
//! this not really a 1:1 `rdiff(1)` implementation, it has the same concepts like generating a
//! signature of a given buffer and then calculating the delta between the original buffer and a... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.