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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
57d04b1a8274ec9282cc7619bf2f97fa316565df | Rust | crispthinking/rust-workshop | /parsing/src/token.rs | UTF-8 | 277 | 3.703125 | 4 | [] | no_license | /// Token Types
#[derive(Debug)]
pub enum Token {
/// A word
///
/// Made up of consecutive alphabetic characters
Word(String),
/// A numeric value
Number(u32),
/// Punctuation
///
/// Anything that's not alphanumeric
Punct(String),
}
| true |
eae66d140252a65f20c79da78ac0fe2b11175cce | Rust | texbois/salmonbot | /src/behavior/test.rs | UTF-8 | 1,534 | 2.59375 | 3 | [] | no_license | use crate::behavior::{Behavior, ThreadResult};
use crate::img_match::ImageMatcher;
use crate::vkapi::{Client, VkApi, VkMessage, VkMessagesApi, VkPhotosApi};
pub struct TestBehavior {
matcher: ImageMatcher,
}
impl TestBehavior {
pub fn new() -> Self {
let matcher = ImageMatcher::new();
Self { m... | true |
be803ee9f9a41dc10f2ccc460b1c60392159b3c2 | Rust | kaikalii/graphics_buffer | /examples/window.rs | UTF-8 | 2,651 | 3.109375 | 3 | [
"MIT"
] | permissive | use graphics::{ellipse, image, text, Transformed};
use graphics_buffer::*;
use piston_window::{
clear, Event, Loop, PistonWindow, TextureSettings, UpdateArgs, WindowSettings,
};
fn main() {
// Load Matt Damon
let matt = RenderBuffer::decode_from_bytes(include_bytes!("matt.jpg")).unwrap();
// Load the ... | true |
6c7dc005e028a6fd83d4de7145fe8b836f8c498b | Rust | tanium/octobot | /lib/src/db/db.rs | UTF-8 | 2,990 | 3.359375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::collections::HashMap;
use anyhow::anyhow;
use log::error;
use rusqlite::types::FromSql;
use crate::errors::*;
#[derive(Clone)]
pub struct Database {
db_file: String,
}
pub use rusqlite::{Connection, Row, Statement, Transaction};
impl Database {
pub fn new(db_file: &str) -> Result<Database> {
... | true |
e9a38f369a8e933e884050d325d44b3ec86c5824 | Rust | karjonas/advent-of-code | /2015/day04/src/lib.rs | UTF-8 | 1,788 | 2.90625 | 3 | [] | no_license | extern crate common;
extern crate crypto;
extern crate rayon;
use crypto::digest::Digest;
use crypto::md5::Md5;
use rayon::prelude::*;
const INPUT: &str = "yzbqklnj";
fn hash_input(input: &str, index: usize) -> [u8; 16] {
let mut hasher = Md5::new();
let key = input.as_bytes();
let mut output = [0; 16];
... | true |
00c2bafd8485c8ecac6205772b45e5512b2885ab | Rust | pema4/stack-machine | /src/machine_code/assembly.rs | UTF-8 | 2,004 | 3.359375 | 3 | [] | no_license | use crate::models::{Assembly, Op, Statement};
use super::*;
impl Decompile for Assembly {
type Error = AssemblyDecompileError;
fn decompile(bytes: &[u8]) -> Result<DecompileResult<Self>, Self::Error> {
let mut idx = 0;
let mut result = Vec::new();
while idx < bytes.len() {
... | true |
52f641ccabce61219a6e3e36604aa9ac5657fbe4 | Rust | chinagxwei/rust-by-example | /src/example_20_std_misc/example_20_5_process/mod.rs | UTF-8 | 662 | 2.625 | 3 | [] | no_license | mod example_20_5_1_pipe;
mod example_20_5_2_wait;
#[cfg(test)]
mod tests {
use super::*;
use std::process::Command;
#[test]
fn example_20_5_process() {
let output = Command::new("rustc")
.arg("--version")
.output()
.unwrap_or_else(|e| panic!("failed to exec... | true |
a729a69e8e46ed87cacdc9f69d8ba984133a2978 | Rust | tomasfarias/advent2019 | /src/modules/day5.rs | UTF-8 | 235 | 2.5625 | 3 | [] | no_license | use std::error::Error;
use crate::modules::intcode;
pub fn run(input: &str) -> Result<String, Box<dyn Error>> {
let mut machine = intcode::build_intcode_from_input(input)?;
machine.run();
Ok("Done!".to_string())
}
| true |
73024412ea1e59282aed7383f1623ffdd4e7c42f | Rust | EMO-VRP-Challenge/vrp | /vrp-core/src/solver/evolution.rs | UTF-8 | 6,902 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | use crate::construction::heuristics::InsertionContext;
use crate::construction::Quota;
use crate::models::Problem;
use crate::solver::mutation::{Mutation, Recreate};
use crate::solver::population::DominancePopulation;
use crate::solver::telemetry::Telemetry;
use crate::solver::termination::Termination;
use crate::solve... | true |
6cd0c281a5dd3e53ffea3f29d7f3d5229a5d1429 | Rust | getzola/zola | /components/content/src/front_matter/split.rs | UTF-8 | 6,420 | 3.03125 | 3 | [
"MIT"
] | permissive | use std::path::Path;
use errors::{bail, Context, Result};
use libs::once_cell::sync::Lazy;
use libs::regex::Regex;
use libs::{serde_yaml, toml};
use crate::front_matter::page::PageFrontMatter;
use crate::front_matter::section::SectionFrontMatter;
static TOML_RE: Lazy<Regex> = Lazy::new(|| {
Regex::new(
r... | true |
64d76eede259959876a07daff839c995d85d3328 | Rust | ikanago/mini_ml | /src/parser/mod.rs | UTF-8 | 4,042 | 3.40625 | 3 | [
"MIT"
] | permissive | pub mod parser;
pub mod typing;
use std::collections::HashSet;
use std::convert::From;
// Type substitution rules of type variable.
pub type Substitutions = Vec<(usize, Type)>;
#[derive(Clone, Debug, PartialEq)]
pub enum BinOpKind {
Add,
Sub,
Mul,
Lt,
Gt,
}
#[derive(Clone, Debug, PartialEq)]
pub... | true |
b02789edf4c5a5897e05ca672f27c4351584245c | Rust | kejadlen/katas | /understanding-computation/src/main.rs | UTF-8 | 317 | 3.140625 | 3 | [
"MIT"
] | permissive | #![feature(inclusive_range_syntax)]
fn main() {
let result: Vec<String> = (1...100)
.map(|n| match n {
n if n % 15 == 0 => "FizzBuzz".into(),
n if n % 3 == 0 => "Fizz".into(),
n if n % 5 == 0 => "Buzz".into(),
n => format!("{}", n),
})
.collect();
println!("{:?}", result);
}
| true |
a61785649a9787bbed1e3e2ef67d1195b58106e1 | Rust | Progdrasil/sea-query | /sea-query-derive/src/error.rs | UTF-8 | 939 | 2.703125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use syn::Ident;
use crate::iden_path::IdenPath;
#[derive(Debug, thiserror::Error)]
pub enum ErrorMsg {
#[error("Only the attributes `#[iden = \"name\"]` or `#[iden(rename = \"name\") are supported in this position")]
ContainerAttr,
#[error("Must be a string literal")]
WrongLiteral,
#[error("The me... | true |
22fab97fa66b489d2fc8f230ff13309bd39772e6 | Rust | franizus/rust-curse | /src/main.rs | UTF-8 | 931 | 3.453125 | 3 | [] | no_license | use std::mem;
fn main()
{
// u -> unsigned integer 0...255; i -> signed integer -127...128
let a:u8 = 123; //8 bits
println!("a = {}", a);
//a = 456;
// mutable = changable
let mut b:i8 = 0;
println!("b = {}", b);
b = 42;
println!("b = {}", b);
let mut c = 123456789; //32-bit signed i32
println!("c = {},... | true |
fe5ca747d8e5ebbdf38f6804cc43ae69a6bffbc7 | Rust | KuabeM/cargo-spellcheck | /src/config.rs | UTF-8 | 9,633 | 2.65625 | 3 | [] | no_license | //! Configure cargo-spellcheck
//!
//! Supports `Hunspell` and `LanguageTool` scopes.
//!
//! A default configuration will be generated in the default
//! location by default. Default. Default default default.
use crate::suggestion::Detector;
use anyhow::{anyhow, Error, Result};
use log::trace;
use serde::{Deserialize... | true |
a686cf3bf258a73b864b04de36b78b91ee70ccc9 | Rust | awslabs/tough | /tough/tests/interop.rs | UTF-8 | 3,686 | 2.640625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT OR Apache-2.0
use std::fs::File;
use tempfile::TempDir;
use test_utils::{dir_url, read_to_end, test_data};
use tough::{FilesystemTransport, Limits, Repository, RepositoryLoader, TargetName};
mod test_utils;
///... | true |
172a9d7e3daefd2036e2a1c00a684dbccbca2cf7 | Rust | Lancewiu/codewars | /rust/minibitmove/src/lib.rs | UTF-8 | 726 | 2.890625 | 3 | [] | no_license | mod mbm;
#[cfg(test)]
mod tests {
use crate::mbm;
#[test]
fn basic_tests() {
// flip every bit
assert_eq!(mbm::interpreter("10", "1010101"), "0101010");
// flip every other bit
assert_eq!(mbm::interpreter("100", "1111111111"), "0101010101");
// donothing
ass... | true |
7ed755939b1d6c0c7ac9a807af836a7d62d29c65 | Rust | terassyi/algorithm | /abc/163/e-active-infants/src/main.rs | UTF-8 | 1,111 | 2.765625 | 3 | [] | no_license | fn main() {
let (n, a) = input();
println!("{}", solve(n, a));
}
fn input() -> (i64, Vec<i64>) {
let mut buf1 = String::new();
let mut buf2 = String::new();
buf1.pop();
buf2.pop();
let n: i64 = buf1.parse().unwrap();
let buf = buf2.split_whitespace();
let a: Vec<i64> = buf.map(|b| b... | true |
f8699416eb780665501531a485818d13cb4d6b23 | Rust | Daniel-del-Castillo/ia1 | /grid/src/content.rs | UTF-8 | 1,063 | 2.953125 | 3 | [
"MIT"
] | permissive | use crossterm::style::Colorize;
use std::fmt;
#[derive(Clone, Copy)]
pub enum Content {
Car,
Goal,
Wall,
Empty,
Trace(Direction),
Explored,
}
#[derive(Clone, Copy)]
pub enum Direction {
Left,
Up,
Right,
Down,
}
impl fmt::Display for Content {
fn fmt(&self, f: &mut fmt::For... | true |
a7b781eac3f369364d501293f7409d0e47cd6f66 | Rust | gordonhart/bfi | /examples/toy.rs | UTF-8 | 422 | 2.890625 | 3 | [
"WTFPL"
] | permissive | extern crate bfi;
// Run with `cargo run --example toy`
fn main() {
let program: &str = ",[.[-],]";
let input: &[u8] = b"toy test!";
match bfi::execute(program, input) {
Ok(output_vec) => {
let output_str: &str = std::str::from_utf8(output_vec.as_slice()).unwrap();
println!(... | true |
3f570ece9dc8bde6e7520a67b3727666500bb067 | Rust | piedoom/s | /src/systems/weapon.rs | UTF-8 | 2,471 | 2.65625 | 3 | [] | no_license | use crate::components as c;
use amethyst::core::{
math::{Unit, Vector3},
Float, Time, Transform,
};
use amethyst::{
ecs::{prelude::*, world::LazyUpdate, Entities, Join, Read, System, WriteStorage},
renderer::{SpriteRender},
};
use crate::assets::ResourceCollection;
#[derive(Default, Debug)]
pub struct ... | true |
4a888eff2161d6043dd82cebf49ebef208da9e14 | Rust | meebear/clip | /tests/argtype_test.rs | UTF-8 | 2,011 | 3.015625 | 3 | [] | no_license | #[macro_use]
extern crate clip;
use clip::{ArgType, TrCustom};
#[test]
fn test_argtype_builtin() {
let var = ArgType::Text(Some("helo".to_string()));
assert_eq!(clip_value_at!(&var, Text), Some("helo".to_string()));
let var = ArgType::Text(None);
assert_eq!(clip_value_at!(&var, Text), None);
let... | true |
171785d665093c43f15d92ea3dce0c31a0876e2e | Rust | sbchaos/cake | /src/ofs/file_info.rs | UTF-8 | 3,408 | 3.453125 | 3 | [
"MIT"
] | permissive | use crate::ofs::utils::size_human;
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
pub struct VersionFile {
pub deleted: bool,
pub size: u64,
pub layer_id: String,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct FileInfo {
pub name: String,
pub size: u64,
pu... | true |
ebbf6e0f98c1af1ae9a6911053bd22928a5ba386 | Rust | reitermarkus/parallel-systems | /a02/e02/heat_stencil_1d_mpi.rs | UTF-8 | 4,660 | 2.6875 | 3 | [] | no_license | use std::{env, mem, process::exit, time::Instant};
use mpi::{point_to_point::{Destination, Source}, request::WaitGuard, topology::Communicator};
fn main() {
let room_size: usize = env::args().nth(1)
.map(|n| n.parse().expect("Failed to parse argument"))
.unwrap_or(2000);
let start_time = Instant::now();
... | true |
a3db4145044cffeec4c50a8b2f87a5ac3488c906 | Rust | fabianschuiki/moore | /src/vhdl/syntax/parser/core.rs | UTF-8 | 11,603 | 2.765625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Copyright (c) 2016-2021 Fabian Schuiki
use crate::lexer::token::*;
use crate::parser::rules::{Parser, Recovered, RecoveredResult, Reported, ReportedResult};
use moore_common::errors::*;
use moore_common::name::*;
use moore_common::source::*;
use std;
use std::fmt::Display;
use std::marker::PhantomData;
/// A predi... | true |
c7b55878fb39fc852234ca67831e1a8304bc80f6 | Rust | redox-os/ion | /src/lib/parser/pipelines.rs | UTF-8 | 35,671 | 2.765625 | 3 | [
"MIT"
] | permissive | use std::iter::Peekable;
use thiserror::Error;
use crate::{
expansion::pipelines::{Input, PipeItem, PipeType, Pipeline, RedirectFrom, Redirection},
parser::lexers::arguments::{Field, Levels, LevelsError},
shell::Job,
types::*,
};
const ARG_DEFAULT_SIZE: usize = 10;
/// An error produced during pipeli... | true |
71155977ec241f73422a5afc904a45f86ddb9698 | Rust | dimforge/nalgebra | /src/base/construction.rs | UTF-8 | 43,043 | 2.921875 | 3 | [
"Apache-2.0"
] | permissive | #[cfg(all(feature = "alloc", not(feature = "std")))]
use alloc::vec::Vec;
#[cfg(feature = "arbitrary")]
use crate::base::storage::Owned;
#[cfg(feature = "arbitrary")]
use quickcheck::{Arbitrary, Gen};
use num::{Bounded, One, Zero};
#[cfg(feature = "rand-no-std")]
use rand::{
distributions::{Distribution, Standard... | true |
1784827099500998a1c6c51df7cfe8cb7378708e | Rust | abnerfs/plugins-api-rust | /src/plugins/repository.rs | UTF-8 | 2,722 | 2.71875 | 3 | [] | no_license | use crate::open_connection;
use crate::structs;
use crate::structs::NewPlugin;
use mysql::prelude::*;
use structs::Plugin;
pub fn get_last_plugin() -> Result<Plugin, String> {
let mut conn = open_connection()?;
match conn.exec_first(
"SELECT id, name, description, price, link_git FROM Plugins ORDER BY... | true |
3d085f2bae61b2d2665abe45f933b54b2714a383 | Rust | shino16/cp_rust | /src/math/mat.rs | UTF-8 | 786 | 2.9375 | 3 | [
"CC0-1.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::num::*;
pub type Mat<T> = Vec<Vec<T>>;
pub fn eye<T: Ring>(n: usize) -> Mat<T> {
let mut res = vec![vec![T::zero(); n]; n];
for i in 0..n {
res[i][i] = T::one();
}
res
}
pub fn mat_mul<T: Ring>(a: &Mat<T>, b: &Mat<T>) -> Mat<T> {
let mut res = vec![vec![T::zero(); b[0].len()]; ... | true |
aa85c138ded14af5cb82a77ec756e39fcdc22331 | Rust | madadam/glium | /src/compatibility/nalgebra.rs | UTF-8 | 4,850 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | //! Allow to use nalgebra types as attributes and uniforms.
extern crate nalgebra;
use uniforms::{AsUniformValue, UniformValue};
use vertex::{Attribute, AttributeType};
use self::nalgebra::{Matrix2, Matrix3, Matrix4,
Point1, Point2, Point3, Point4,
Vector1, Vector2, Vector3, ... | true |
09fc22edcd2e081734ae1af586d66e89fd6c303c | Rust | weworld/rusty-leetcode | /src/dp_tag/bomb_enemy_361.rs | UTF-8 | 1,895 | 2.890625 | 3 | [
"WTFPL"
] | permissive | /*
* @lc app=leetcode.cn id=361 lang=rust
*
* [361] 轰炸敌人
*/
// @lc code=start
const DIRECTIONS: [(isize, isize); 4] = [(0, 1), (0, -1), (1, 0), (-1, 0)];
impl Solution {
pub fn max_killed_enemies(grid: Vec<Vec<char>>) -> i32 {
let rows = grid.len();
let cols = if rows == 0 { 0 } else { grid[0]... | true |
b66c47910cb964668becb71e920c2847aa40bb52 | Rust | adrienthebo/dyson | /src/hcl2/ast.rs | UTF-8 | 10,989 | 3.046875 | 3 | [] | no_license | use std::error::Error;
use std::fmt;
use std::str::FromStr;
#[derive(Debug)]
pub struct ParseAstError;
impl fmt::Display for ParseAstError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Unable to parse HCL AST node")
}
}
impl Error for ParseAstError {
fn description(&self) ->... | true |
895d8ee1054c3d72e3547f91209feca5650577d0 | Rust | KristianWahlroos/RustPractice | /adder/src/lib.rs | UTF-8 | 1,484 | 3.578125 | 4 | [] | no_license | #[cfg(test)]
mod tests {
use super::*;
#[test]
fn this_is_an_awkward_silence() {
assert_eq!(2 + 2, 4);
}
#[test]
#[ignore]
fn larger_can_hold_smaller() {
let larger = Rectangle { length: 8, width: 7 };
let smaller = Rectangle { length: 4, width: 5 };
a... | true |
026f38519a7826c4dfcc4fd7866483a69cf8954e | Rust | leops/hatchet | /lang/src/hct/parser.rs | UTF-8 | 8,245 | 2.890625 | 3 | [
"MIT"
] | permissive | use synom::*;
use synom::space::*;
use super::ast::*;
use super::expression::*;
use atom::Atom;
fn position<P>(input: &str, predicate: P) -> Option<usize> where P: Fn(&str) -> IResult<&str, &str> {
for o in 0..input.len() {
if let IResult::Done(_, _) = predicate(&input[o..]) {
return Some(o);
... | true |
28c35ef586453360d2a48bd96b247406ef9f508c | Rust | pantsbuild/pants | /src/rust/engine/process_execution/src/switched.rs | UTF-8 | 3,440 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::fmt;
use std::fmt::Formatter;
use async_trait::async_trait;
use workunit_store::RunningWorkunit;
use crate::{CommandRunner, Context, FallibleProcessResultWithPlatform, Process... | true |
1e08f4089e9267b9adbf988768475721e0d71239 | Rust | delta62/greek-pc-solver | /src/main.rs | UTF-8 | 372 | 2.515625 | 3 | [] | no_license | mod printer;
mod puzzle;
mod solver;
use printer::Printer;
use puzzle::Puzzle;
use solver::Solver;
fn main() {
let puzzle = Puzzle::new();
let mut solver = Solver::new();
let cells = solver
.find(|rot| puzzle.is_solution(*rot))
.map(|rot| puzzle.cells(&rot))
.unwrap();
let pr... | true |
aec1b129fca2d24c3377ee1a71762e876eef549f | Rust | Roblox/testez | /testez-cli/src/dependencies.rs | UTF-8 | 1,034 | 3.109375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | //! Defines how to handle the different ways that projects using TestEZ-CLI can
//! have their dependencies configured.
//!
//! We support three schemes:
//! - None. No dependencies were detected.
//! - Rotriever. Dependencies are in `Packages`
//! - Git submodules. Dependencies are in `modules/*/src`.
//!
//! If we do... | true |
7f87bd77ac2d71b35a6d11dce0cb2d72005d90f0 | Rust | aq1018/rpizw-test | /src/devices/motor.rs | UTF-8 | 2,162 | 2.703125 | 3 | [
"MIT"
] | permissive | use core::marker::PhantomData;
use embedded_hal::digital::v2::OutputPin;
use embedded_hal::PwmPin;
pub mod ic;
pub struct Motor<IN1, IN2, PWM, E, IC>
where
IN1: OutputPin<Error = E>,
IN2: OutputPin<Error = E>,
PWM: PwmPin,
{
in1: IN1,
in2: IN2,
pwm: PWM,
_ic: PhantomData<IC>,
}
pub enum ... | true |
fab03b4b00db6deecf92cc5cb52ce8ecf8a52a7f | Rust | 0rvar/advent-of-code-2018 | /day02/src/main.rs | UTF-8 | 1,699 | 3.375 | 3 | [] | no_license | use std::collections::HashMap;
fn main() {
let input = include_str!("input.txt");
let box_ids: Vec<&str> = input.trim().split("\n").collect::<Vec<_>>();
let part_1_checksum: usize = box_ids.iter().map(|x| hash(x, 2)).sum::<usize>()
* box_ids.iter().map(|x| hash(x, 3)).sum::<usize>();
println!(... | true |
22a08a5a0e3f238a76b2df40768c2584deac3f6b | Rust | WaffleLapkin/typed_phy | /src/dimensions.rs | UTF-8 | 6,920 | 3.625 | 4 | [
"MIT"
] | permissive | use core::{
fmt,
ops::{Add, Div, Mul, Sub},
};
use typenum::{Diff, Integer, Sum};
/// Trait implemented for [`Dimensions`].
/// Mostly needed to simplify bound and write
/// ```
/// # use typed_phy::DimensionsTrait;
/// # trait Trait {}
/// impl<U: DimensionsTrait> Trait for U {
/// /* ... */
/// }
/// ``... | true |
32fb15e39742daf103bc3c9e9f0cd70ca16a3c2f | Rust | robisys/rust-by-example | /examples/scope/raii/raii.rs | UTF-8 | 619 | 3.40625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // raii.rs
fn create_box() {
// Allocate an integer on the heap
let box1 = Box::new(3i32);
// `box1` is destroyed here, and memory gets freed
}
fn main() {
// Allocate an integer on the heap
let box2 = Box::new(5i32);
// A nested scope:
{
// Allocate an integer on the heap
... | true |
45477d9121738dd958c53c8425308c2fda854d5b | Rust | mockersf/serde_dynamodb | /src/error.rs | UTF-8 | 1,110 | 3.390625 | 3 | [
"MIT"
] | permissive | //! This type represents all possible errors that can occur when serializing or deserializing DynamoDB data.
/// Alias for a Result with the error type `serde_dynamodb::Error`.
pub type Result<T> = std::result::Result<T, Error>;
/// This type represents all possible errors that can occur when serializing to or deseri... | true |
869d35cde40cb31cdf6f6ec5f27302b10072a1ee | Rust | nambrosini/adventofcode | /2015/src/day01.rs | UTF-8 | 1,673 | 3.734375 | 4 | [] | no_license | #[aoc(day1, part1)]
pub fn part1(input: &str) -> i32 {
input.chars().fold(0, |sum, c| {
sum + match c {
'(' => 1,
')' => -1,
_ => unreachable!(),
}
})
}
#[aoc(day1, part2)]
pub fn part2(input: &str) -> i32 {
let mut sum = 0;
for (i, c) in input.chars... | true |
57351653cbf955e494cf47e08aa6744253d19b4b | Rust | UmerMIB/mongo-rust-driver | /src/cmap/conn/mod.rs | UTF-8 | 8,788 | 2.953125 | 3 | [
"Apache-2.0"
] | permissive | mod command;
mod stream;
mod stream_description;
mod wire;
use std::{
sync::{Arc, Weak},
time::{Duration, Instant},
};
use derivative::Derivative;
use self::{stream::Stream, wire::Message};
use super::ConnectionPoolInner;
use crate::{
error::{ErrorKind, Result},
event::cmap::{
CmapEventHandle... | true |
f67ab97ffc1451820fdc147128dd82b9ac14981f | Rust | frankegoesdown/LeetCode-in-Go | /Algorithms/0400.nth-digit/nth-digit.go | UTF-8 | 647 | 3.328125 | 3 | [
"MIT"
] | permissive | package problem0400
func findNthDigit(n int) int {
// step 1: 寻找拥有 NthDigit 的数的位数 digits
// 有 count 个数 是 digits 位数
count, digits := 9, 1
// num 是最小的 digits 位数
num := 1
for n-count*digits > 0 {
n -= count * digits
count *= 10
digits++
num *= 10
}
// step 2: 找到拥有 NthDigit 的数
// index 是 NthDigit 是目标数中的 ... | true |
baf0c704269968606632fcaf71ff5db962f9675c | Rust | katcipis/playground | /rust/fibo/src/lib.rs | UTF-8 | 680 | 3.5625 | 4 | [] | no_license | pub fn fib(n: i64) -> i64 {
fn fibrec(n: i64, a: i64, b: i64) -> i64 {
if n <= 0 {
return a;
}
fibrec(n - 1, b, a + b)
}
fibrec(n, 0, 1)
}
#[cfg(test)]
mod test {
use super::fib;
const TESTCASES: &[(i64, i64)] = &[
(0, 0),
(1, 1),
(2, 1),... | true |
7a3f844ffb68b9250697a5762cb37bb9bb3f32cc | Rust | luiz787/p2p-video-transfer | /common/src/query_info.rs | UTF-8 | 2,317 | 2.953125 | 3 | [] | no_license | use crate::byte_utils;
use crate::chunk_list::ChunkList;
use core::panic;
use std::net::{IpAddr, SocketAddr};
pub struct QueryInfo {
pub message_type: u16,
pub address: SocketAddr,
pub peer_ttl: u16,
pub chunk_info: ChunkList,
}
impl QueryInfo {
pub fn new(message: &[u8], bytes_read: usize) -> Res... | true |
4c42ac0cfc83573c9f81051439d6c3294ef3a779 | Rust | ragne/bloom | /benches/bloom.rs | UTF-8 | 1,416 | 2.828125 | 3 | [] | no_license | use bit_vec::BitVec;
use bloom::BloomFilter;
use criterion::{criterion_group, criterion_main, Criterion};
use rand::distributions::Uniform;
use rand::Rng;
fn insert_item(b: &mut Criterion) {
let mut f = BloomFilter::with_fp_size(0.05, 50000);
let mut gen = rand::thread_rng();
let item = gen.sample(Uniform:... | true |
64f57109f7d6900d2f312967514f28b255ac64ba | Rust | monkeylyf/interviewjam | /recursion/leetcode_binary_watch.rs | UTF-8 | 2,583 | 3.703125 | 4 | [] | no_license | /**
* A binary watch has 4 LEDs on the top which represent the hours (0-11), and
* the 6 LEDs on the bottom represent the minutes (0-59).
*
* Each LED represents a zero or one, with the least significant bit on the
* right.
*
* For example, the above binary watch reads "3:25".
*
* Given a non-negative integer ... | true |
bfe0eec1696eb20f777e11632358c9d6ad0392bd | Rust | faradayio/catcsv | /src/main.rs | UTF-8 | 6,365 | 2.875 | 3 | [] | no_license | //! Given a list of CSV files, directories containing CSV files, compressed
//! CSV files, or some combination of the above, concatenate all the CSV files
//! together as quickly as we can.
//!
//! This replaces a 20-line shell script with two pages of Rust. But it has
//! a much nicer UI and it handles the corner case... | true |
4f9b564a27c2fd53b9332ee9883726ca3d0676a6 | Rust | control9/frustoz | /frustoz-core/src/render/filter/log_filter.rs | UTF-8 | 892 | 2.546875 | 3 | [
"MIT"
] | permissive | use crate::render::HDRPixel;
use super::LogFilter;
impl LogFilter {
pub fn new(quality: u32, oversampling: u32, width: f64, height: f64, brightness: f64) -> Self {
let area = width * height;
let k1 = brightness * 2.0;
let k2 = oversampling as f64 * oversampling as f64 / (area * quality as... | true |
2a115b01790496c968fc2402b3148038a2ce3a96 | Rust | 715209/obs-websocket-rs | /src/events/profiles.rs | UTF-8 | 616 | 2.796875 | 3 | [
"MIT"
] | permissive | use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
/// Triggered when switching to another profile or when renaming
/// the current profile.
/// Added in v4.0.0
pub struct ProfileChanged {
/// Name of the new current profile.
pub profile: String,
}
#[derive(Serialize, Deserialize, D... | true |
2324dc9d5181c52ebbfd7cd63f7607140441e1a8 | Rust | alaskacanyon/ion | /src/lib/parser/statement/splitter.rs | UTF-8 | 14,314 | 2.953125 | 3 | [
"MIT"
] | permissive | // TODO:
// - Rewrite this in the same style as shell_expand::words.
// - Validate syntax in methods
use std::fmt::{self, Display, Formatter};
#[derive(Debug, Clone, Copy, Hash, Eq, PartialEq)]
enum LogicalOp {
And,
Or,
None,
}
#[derive(Debug, PartialEq)]
pub enum StatementError {
IllegalCommandName(... | true |
80eba844e9b29bd2fc45599d115c6d81ba1c842c | Rust | alexcrichton/rust-central-station | /sync-github/src/main.rs | UTF-8 | 9,310 | 2.828125 | 3 | [] | no_license | mod github;
use crate::github::{GitHub, TeamPrivacy, TeamRole};
use failure::{Error, ResultExt};
use log::{debug, error, info, trace, warn};
use std::borrow::Cow;
use std::collections::{HashMap, HashSet};
use std::path::PathBuf;
use std::process::Command;
static DEFAULT_DESCRIPTION: &str = "Managed by the rust-lang/t... | true |
7c5a3633058a97904b90c39b522eb29e63a44998 | Rust | attilahorvath/advent-of-code-2019 | /day17/src/main.rs | UTF-8 | 279 | 2.578125 | 3 | [
"MIT"
] | permissive | use std::error::Error;
use std::fs;
use day17::*;
fn main() -> Result<(), Box<dyn Error>> {
let program = fs::read_to_string("input.txt")?;
let alignment = calculate_alignment(program.trim())?;
println!("Sum of alignment parameters: {}", alignment);
Ok(())
}
| true |
0ef554d4b275d1c0100d2691a86e22602b222033 | Rust | yenwel/db | /src/main.rs | UTF-8 | 2,140 | 2.984375 | 3 | [] | no_license | extern crate cmdr;
use cmdr::*;
struct SQLScope {}
/// Example scope that implements two commands, greet and quit
#[cmdr]
impl SQLScope {
fn prompt(&self) -> String {
"db>".to_string()
}
/// Cmdr command to quit the application by returning CommandResult::Quit
#[cmd(quit, help = "Qu... | true |
5de19f289a20089db12e46d2af17967a1c287e99 | Rust | naomijub/serde-encrypt | /serde-encrypt-core/tests/feat_serde_encrypt_std_error.rs | UTF-8 | 546 | 2.578125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! serde_encrypt::error::Error implements std::error::Error in `std` feature.
#![cfg(feature = "std")]
mod test_util;
// https://rust-lang.github.io/api-guidelines/interoperability.html#error-types-are-meaningful-and-well-behaved-c-good-err
#[test]
fn test_api_guidelines_c_good_err() {
use std::fmt::Display;
... | true |
552d91ee3ba73f9479b18a79cbef9f1a41c2dd01 | Rust | gregparsons/actor-crossbeam-rust | /src/pinger_actor.rs | UTF-8 | 3,031 | 3 | 3 | [] | no_license |
use std::time::{Duration, Instant};
use crossbeam_channel::{Sender, Receiver};
use std::thread::{spawn};
use crate::actor_tools::MsgActor;
pub struct Actor {
name:String,
inbound_multi_producer:crossbeam_channel::Sender<MsgActor>,
inbound_single_consumer:crossbeam_channel::Receiver<MsgActor>,
pub parent_tx:Sende... | true |
13027cf116cf758a495a164e21b4f664364a032b | Rust | lowdown1983/ecu_diagnostics | /src/kwp2000/security_access.rs | UTF-8 | 1,757 | 3.125 | 3 | [
"MIT"
] | permissive | //! Functions for unlocking secure regions on the ECU
use crate::{DiagError, DiagServerResult};
use super::{KWP2000Command, Kwp2000DiagnosticServer};
/// Requests a seed from the ECU
///
/// ## Parameters
/// * server - The KWP2000 server
/// * access_mode - The access mode. Only odd numbers between 0x01-0x7F are ... | true |
2256be4e867d0eb12b58a3273367cb0b295df0d0 | Rust | norman784/gaiku | /benches/heightmap.rs | UTF-8 | 4,612 | 2.6875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | #![feature(test)]
extern crate test;
use gaiku::{
common::{
chunk::Chunk,
mesh::Mesh,
prelude::*,
texture::{Texture2d, TextureAtlas2d},
Result,
},
GoxReader, HeightMapBaker,
};
use test::Bencher;
fn get_chunks(name: &str) -> Result<(Vec<Chunk>, Option<TextureAtlas2d<Texture2d>>)> {
let fi... | true |
e1deb1e899763fc90df6e7cc50f6a7fffeb1488f | Rust | iqlusioninc/abscissa | /core/src/config/cell.rs | UTF-8 | 1,203 | 3.34375 | 3 | [
"Apache-2.0"
] | permissive | //! Configuration cell: holder of application configuration.
use super::{Config, Reader};
use arc_swap::ArcSwapOption;
use std::sync::Arc;
/// Configuration cell: holder of application configuration.
#[derive(Debug, Default)]
pub struct CfgCell<C: Config> {
/// Inner configuration state
inner: ArcSwapOption<C... | true |
41fe97f754f85dfb7b5fc0d4771863e0ae403d64 | Rust | DoN-SultaN/pants | /src/rust/engine/fs/store/src/local.rs | UTF-8 | 11,848 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | use super::{EntryType, ShrinkBehavior, GIGABYTES};
use std::collections::BinaryHeap;
use std::path::Path;
use std::sync::Arc;
use std::time::{self, Duration};
use bytes::Bytes;
use digest::{Digest as DigestTrait, FixedOutput};
use futures::future;
use hashing::{Digest, Fingerprint, EMPTY_DIGEST};
use lmdb::Error::Not... | true |
ec3f3bb5c6f4700f73f2214078981f231c96d4e5 | Rust | FIU-SCIS-Senior-Projects/WEB-VR-Towards-Virtual-and-Augmented-Reality-for-the-WEB-1.0 | /Code/webvr-input/src/devices/mouse.rs | UTF-8 | 5,723 | 3.390625 | 3 | [] | no_license | use spat_input::{InputAdapter, ConnectionMode, SubInput };
use std::collections::HashSet;
use std::time::{Duration,Instant};
use std::thread::sleep;
impl SubInput<i32> {
pub fn new() -> SubInput<i32>{
SubInput {
min: 0,
current: 0,
max: 9999,
}
}
}
//The di... | true |
455d662d7300573a42f0d855a241ae18abe4f7c0 | Rust | fextivity/rviewer | /src/figure/poly.rs | UTF-8 | 2,590 | 2.984375 | 3 | [] | no_license | use crate::figure::Figure;
use crate::app_data::DrawProperties;
use crate::poly::Poly;
use druid::widget::prelude::*;
use druid::{Color, Point};
pub struct MPoly {
points: Vec<Point>,
fill: bool,
width: f64,
color: Color,
tags: Vec<String>,
}
impl MPoly {
pub fn from_string(s: &str, draw_prop... | true |
46397a52d117ad96ded0ff9deb7fa2b6cf832c1c | Rust | iCodeIN/wsmq-rs | /tests/test.rs | UTF-8 | 41,955 | 2.53125 | 3 | [
"MIT"
] | permissive | use futures::executor::block_on;
use std::{
convert::TryInto,
net::SocketAddr,
sync::{Arc, Mutex},
time::Duration,
};
use wsmq::{client, server};
mod protos {
pub mod test;
}
macro_rules! define_test_future {
($test_code:expr) => {{
let (svc, inst) = service::Service::new();
le... | true |
45ef157dd10843067d94e1dc1c87326243895a1c | Rust | ke-pan/leetcode-rust | /src/n385_mini_parser.rs | UTF-8 | 2,678 | 3.6875 | 4 | [] | no_license | /*
* @lc app=leetcode id=385 lang=rust
*
* [385] Mini Parser
*
* https://leetcode.com/problems/mini-parser/description/
*
* algorithms
* Medium (31.71%)
* Total Accepted: 28.8K
* Total Submissions: 90.8K
* Testcase Example: '"324"'
*
* Given a nested list of integers represented as a string, implement ... | true |
17b4da9fa5b6997fbb3fed9e6e4c6dece62350c1 | Rust | KaiseiYokoyama/rs-mahjong | /src/parse.rs | UTF-8 | 8,205 | 3.171875 | 3 | [] | no_license | use crate::groups::{Hand, OpenSet, Set, Tiles, TilesNewType};
use crate::tiles::Tile;
use std::fmt::{Display, Formatter, Error};
/// 手牌をパースする
#[derive(Debug)]
pub struct ParsedHand {
/// 手牌(晒した牌を含む)
pub tiles: Vec<Tile>,
/// 最終形候補
pub nodes: Vec<Node>,
/// 当たり牌
pub winning: Tile,
}
impl Parsed... | true |
1fedafcf78345be519fd6cfae44defad09d279ae | Rust | TechieDheeraj/learn-rust | /hello_world_001/src/pointer_ref.rs | UTF-8 | 445 | 4.1875 | 4 | [] | no_license | pub fn run() {
// Primitive Array
let arr1 = [1, 2, 3];
let arr2 = arr1;
// With Non-premitives, if you assign another variable to a piece of data, the first variable
// will no longer hold that value. You'll need to use a reference (&) to point to the resource.
// Vector
let arr3 = vec![1... | true |
72a7c1de102805af8599d6c607b7c78225c38444 | Rust | juripero/MeiliDB | /meilidb-core/src/store.rs | UTF-8 | 896 | 2.65625 | 3 | [
"MIT"
] | permissive | use std::error::Error;
use fst::Set;
use sdset::SetBuf;
use crate::DocIndex;
pub trait Store {
type Error: Error;
fn words(&self) -> Result<&Set, Self::Error>;
fn word_indexes(&self, word: &[u8]) -> Result<Option<SetBuf<DocIndex>>, Self::Error>;
fn synonyms(&self) -> Result<&Set, Self::Error>;
fn... | true |
f9a25588eb796841ee6616a91f6932726f832b3b | Rust | kiskoza/30days-of-rust | /day10/src/main.rs | UTF-8 | 496 | 2.625 | 3 | [] | no_license | #[macro_use] extern crate text_io;
use itertools::Itertools;
fn main() {
let n: i32 = read!();
let mut bits = vec!();
let mut i = n;
while i > 0 {
bits.push(i % 2);
i = i / 2;
}
let max = bits
.into_iter()
.map(|c| (c, 1))
.coalesce( |(x, nx), (y, ny)|
if x == y {
Ok((... | true |
dd98afb979448fb03661dcf824c38cdcda6b37d8 | Rust | noeddl/ukebox | /src/chord_type.rs | UTF-8 | 17,349 | 2.828125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::cmp::min;
use std::convert::TryFrom;
use std::fmt;
use std::str::FromStr;
use crate::{Interval, PitchClass, PITCH_CLASS_COUNT, STRING_COUNT};
/// The type of the chord depending on the intervals it contains.
///
/// Sources used:
///
/// * <https://en.wikipedia.org/wiki/Chord_(music)>
/// * <https://en.wikip... | true |
b96dbd29792eed209d94333ff488bb59998361cd | Rust | thebargaintenor/raytracer-rs | /src/engine/materials/lambertian.rs | UTF-8 | 648 | 2.890625 | 3 | [] | no_license | use super::super::math;
use super::{
Color,
Hit,
Ray,
Scatter,
Scatterable,
Vec3,
};
pub struct Lambertian {
albedo: Color,
}
impl Scatterable for Lambertian {
/// Ray interaction with diffuse material
#[allow(unused_variables)] // incident ray not a factor in calculation
fn sc... | true |
3656060b7d38ca24ce3b6eeb9bf534dca445115f | Rust | Gogomoe/LeetCodeSolutions | /src/0082.rs | UTF-8 | 1,182 | 3.328125 | 3 | [] | no_license | impl Solution {
pub fn delete_duplicates(mut head: Option<Box<ListNode>>) -> Option<Box<ListNode>> {
let mut node = &mut head;
let mut is_dup = false;
while node.is_some() && node.as_ref().unwrap().next.is_some() {
if node.as_ref().unwrap().val == node.as_ref().unwrap().next.as_r... | true |
431a9e5ec86f4c033ff276f01858b46f4fa4a4aa | Rust | jameslittle230/stork | /stork-lib/src/index_v3/build/annotated_words_from_string.rs | UTF-8 | 2,614 | 3.125 | 3 | [
"Apache-2.0"
] | permissive | use crate::{index_v3::AnnotatedWord, InternalWordAnnotation};
pub(super) trait AnnotatedWordable {
fn make_annotated_words(&self) -> Vec<AnnotatedWord>;
fn make_annotated_words_with_annotations<F>(&self, closure: F) -> Vec<AnnotatedWord>
where
F: Fn(&str, &mut Vec<InternalWordAnnotation>);
}
impl ... | true |
c5b107dbdae47b6ce12cd4de166c01468d581e0e | Rust | jjyr/restricted-sparse-merkle-tree | /src/default_store.rs | UTF-8 | 1,830 | 2.9375 | 3 | [
"MIT"
] | permissive | use crate::{
collections,
error::Error,
traits::Store,
tree::{BranchNode, LeafNode},
H256,
};
#[derive(Debug, Clone, Default)]
pub struct DefaultStore<V> {
branches_map: Map<H256, BranchNode>,
leaves_map: Map<H256, LeafNode<V>>,
}
impl<V> DefaultStore<V> {
pub fn branches_map(&self) ->... | true |
cfa53b88edddf1eafce3d0a5b432e02f2a9dbc57 | Rust | iCodeIN/crust | /tests/refcell.rs | UTF-8 | 4,593 | 2.828125 | 3 | [] | no_license | #![feature(no_std)]
#![feature(core)]
// This code is mostly copied from rust/src/libcore/cell.rs, which is distributed under the
// following license:
//
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGH... | true |
94c25791aa7b7b8ceb89b0edbbabe44cb6dccaeb | Rust | zesterer/gui | /src/canvas.rs | UTF-8 | 2,101 | 3 | 3 | [] | no_license | use crate::{
draw::{Fill, Stroke, Color},
layout::Bounds,
};
use vek::*;
pub enum Primitive {
Rect { rect: Rect<f32, f32>, fill: Fill },
Line { line: LineSegment2<f32>, stroke: Stroke },
Text { pos: Vec2<f32>, text: String, height: f32, col: Color },
}
#[derive(Default)]
pub struct Canvas {
pu... | true |
b59889fd84db2b489886da34fc46c644c722e6a5 | Rust | omadoyeabraham/rust-book-codealong | /chapter-5/playground.rs | UTF-8 | 435 | 3.3125 | 3 | [] | no_license | #[derive(Debug)]
struct Task {
id: String,
title: String,
description: String,
completed: bool,
}
fn main() {
let mut task_1 = Task {
id: String::from("1"),
description: String::from("Read to lead"),
title: String::from("Man's search for meaning"),
completed: true
... | true |
b204aca11be2365d589c61cc779861b3306680cf | Rust | kideasoft/relay-8-485 | /src/lib.rs | UTF-8 | 9,541 | 2.890625 | 3 | [] | no_license | //! A platform agnostic driver to interface with the 8 channel Relay (RS485)
use chrono;
use crc16::*;
use serialport::SerialPort;
#[derive(Debug)]
pub enum Error {
SerialError(serialport::Error),
IoError(std::io::Error),
DecodeError,
ResponseError,
StatusError,
OpFailed,
}
pub enum ChannelNu... | true |
f7c0ac9e7bc0993b32a311f4bc164c9b47bd5061 | Rust | vincenthouyi/LakeOS | /lib/naive/src/os_str_bytes.rs | UTF-8 | 9,323 | 3.09375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! The underlying OsString/OsStr implementation on Unix and many other
//! systems: just a `Vec<u8>`/`[u8]`.
use crate::os_str::{OsStr, OsString};
use alloc::borrow::Cow;
use alloc::rc::Rc;
use alloc::sync::Arc;
use core::fmt;
use core::mem;
use core::str;
use core::str::from_utf8_unchecked;
// use crate::sys_common:... | true |
cd6dcc791b852875d301264b47219a3c7426eef5 | Rust | GuilloteauQ/GraphViewer | /src/points.rs | UTF-8 | 2,557 | 3.546875 | 4 | [] | no_license | // pub mod svg;
extern crate rand;
use svg::*;
#[derive(Debug, Clone, Copy)]
pub struct Point {
pub x: u32,
pub y: u32,
}
impl Point {
/// Returns a new point
pub fn new(x: u32, y: u32) -> Point {
Point { x, y }
}
/// Returns a random point inside the rectangle n*m
pub fn random_... | true |
de968759390139e472efcea8248ae99ed8a6686d | Rust | lucadonnoh/pathfinder | /crates/pathfinder/examples/fact_retrieval.rs | UTF-8 | 4,838 | 2.625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Demonstrates how to retrieve a StarkNet state update from L1 using event logs.
//!
//! As a high-level overview of the log events:
//! (in chronological order, for a single state update)
//!
//! 1. Multiple LogMemoryPageFactContinuous get emitted by the MemoryPageFactRegistry contract.
//! These logs con... | true |
00b08a8e1321da06265ca1990d1ef4bb2ab037f0 | Rust | lamalex/liftright-data-server | /liftright_data_server_core/src/user.rs | UTF-8 | 1,232 | 2.625 | 3 | [] | no_license | use crate::{LrdsError, LrdsResult};
use mongodb::bson;
use serde::{Deserialize, Serialize};
use std::convert::TryFrom;
use uuid::Uuid;
#[derive(Debug, PartialEq, Clone, Copy, Serialize, Deserialize)]
pub struct User {
device_id: Uuid,
}
#[derive(Debug, PartialEq, Clone, Copy, Serialize, Deserialize)]
struct RtfbS... | true |
4c86b6c84fa3d57a24808233ef4d09c5800b74e5 | Rust | devonhollowood/adventofcode | /2017/day14/src/main.rs | UTF-8 | 4,074 | 2.8125 | 3 | [
"MIT"
] | permissive | extern crate structopt;
#[macro_use]
extern crate structopt_derive;
use structopt::StructOpt;
fn bits(byte: u8) -> Vec<bool> {
vec![
byte >> 7 & 0x1 == 0x1,
byte >> 6 & 0x1 == 0x1,
byte >> 5 & 0x1 == 0x1,
byte >> 4 & 0x1 == 0x1,
byte >> 3 & 0x1 == 0x1,
byte >> 2 & 0... | true |
5c1b8c9151616436712b470fdee9fbb396ade042 | Rust | tstellanova/zephyr-rust | /rust/zephyr-core/src/time.rs | UTF-8 | 3,478 | 3.359375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | use core::convert::{TryFrom, TryInto};
use core::fmt;
use core::num::TryFromIntError;
use core::time::Duration;
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash, From)]
pub struct InstantMs(i64);
impl InstantMs {
pub const fn zero() -> Self {
Self(0)
}
pub fn checked_add(self, rh... | true |
2d82c2e571285bdb092acd226b77b892eee8fc87 | Rust | lalrpop/lalrpop | /lalrpop/src/lr1/report/mod.rs | UTF-8 | 11,979 | 2.75 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::collections::*;
use crate::grammar::repr::*;
use crate::lr1::core::*;
use std::cmp::max;
use std::io::{self, Write};
use super::lookahead::*;
pub fn generate_report<'grammar, W: Write + 'grammar>(
out: &'grammar mut W,
lr1result: &Lr1Result<'grammar>,
) -> io::Result<()> {
let mut generator = R... | true |
2e8b124baa11e7a4ef42c733df6513aa376b10ee | Rust | Skarlett/sizeof-rs | /src/main.rs | UTF-8 | 1,361 | 3.078125 | 3 | [] | no_license | extern crate walkdir;
use walkdir::WalkDir;
use std::env;
const SIZE_NAMES: &'static [&'static str] = &["B", "KB", "MB", "GB", "TB", "PB"];
fn file_size(fp: &std::path::Path) -> std::io::Result<u128> {
Ok(fp.metadata()?.len() as u128)
}
fn dir_size(fp: &std::path::Path) -> u128 {
let mut bytes: u128 = 0;
... | true |
75c469ae7f3b8e78247bc5575f8009af6620838d | Rust | bennyboer/worklog | /cli/src/command/delete/delete.rs | UTF-8 | 1,215 | 3.25 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use cmd_args::{arg, option, Group};
use crate::command::command::Command;
/// Command used to delete a work item.
pub struct DeleteCommand {}
impl Command for DeleteCommand {
fn build(&self) -> Group {
Group::new(
Box::new(|args, options| execute(args, options)... | true |
efa6c15c9934d5aa8959b3d445bb8b06909832cd | Rust | sproctor/DikuMUD-Rust | /src/main.rs | UTF-8 | 2,240 | 2.515625 | 3 | [] | no_license | #[macro_use] extern crate bitflags;
#[macro_use] extern crate enum_map;
extern crate libc;
extern crate getopts;
extern crate rand;
extern crate time;
extern crate nix;
extern crate chan;
extern crate chan_signal;
extern crate regex;
#[macro_use] extern crate serde_derive;
extern crate bincode;
use std::env;
use std::... | true |
d130ebeee6b56ec2ad76f663032ce247a42ddf65 | Rust | 1BADragon/huffman-rs | /src/freq_tree.rs | UTF-8 | 3,387 | 3.71875 | 4 | [] | no_license | use std::cmp::Ordering;
use bitstream::*;
/// A node of the frequency tree required for huffman encoding. The data of
/// this node is either a composit of nodes or a value which is a byte with
/// a frequency.
pub struct FreqTreeNode {
pub data: FreqNodeData,
}
/// The payload of an ftree node.
pub enum Freq... | true |
66e562cf2f4a47a50a912272ca251350dce12dca | Rust | mnottale/language | /src/libstdlib.rs | UTF-8 | 2,259 | 2.90625 | 3 | [] | no_license |
use std::collections::HashMap;
use Functions;
use Classes;
use Class;
use value::{Value,EValue};
use callable::Callable;
use callable::Convertible;
use callable::Boxable;
use python::load_python;
fn len(v: Value) -> i32 {
match v.evalue() {
EValue::Int(_v) => 1,
EValue::Flt(_v) => 1,
EValue::Str(s) =>... | true |
0041c4e49a04207f409a77a169ee1ae71d3e0cb5 | Rust | tensorbase/tensorbase | /crates/datafusion/src/physical_plan/expressions/negative.rs | UTF-8 | 4,387 | 2.8125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-free-unknown"
] | permissive | // Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may... | true |
28eec3b9d498a3eba51a46925a577b474ab60165 | Rust | torao/bumblebees | /src/msg/mod.rs | UTF-8 | 10,473 | 2.953125 | 3 | [
"MIT"
] | permissive | use std::io::{Read, Write};
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
use uuid::Uuid;
use super::error::Error;
use super::Result;
#[cfg(test)]
mod test;
/// Block のペイロードに設定することのできる最大サイズです。0xEFFF (61,439バイト) を表しています。
pub const MAX_PAYLOAD_SIZE: usize = 0xEFFF;
/// Block の消失確率に設定することのできる最大値です。0x7F ... | true |
6370b0b8832f64881cc256f6f77aa578546816ab | Rust | bushidocodes/hatchling | /src/main.rs | UTF-8 | 2,088 | 2.859375 | 3 | [
"MIT"
] | permissive | use std::process;
use clap::{App, Arg};
use hatchling::convert_facebook_to_solid;
use std::fs::File;
use std::io::prelude::*;
fn main() {
let matches = App::new("hatchling")
.version("0.1")
.about("A tool to convert Facebook data to Linked Data")
.author("Sean McBride")
.arg(
... | true |
617d34671c0a34ba4866410e7190b57f1409d7ce | Rust | krisvanrens/rust-workshop-accu2019 | /src/server/parser.rs | UTF-8 | 3,175 | 3.671875 | 4 | [
"MIT"
] | permissive | #[derive(Debug, PartialEq)]
pub enum Command {
Pub(Vec<String>),
Get(u32)
}
#[derive(Debug, PartialEq)]
pub enum ParseError {
InvalidCommand,
NoArguments,
TooManyArguments,
InvalidArgument
}
pub fn parse_error_to_string(error: ParseError) -> String {
match error {
ParseError::Inv... | true |
2992038b7fdee230ca263902f6f171a9c6abe724 | Rust | frehberg/rtps-rs | /src/messages/vendor_id.rs | UTF-8 | 1,515 | 3.125 | 3 | [
"Apache-2.0"
] | permissive | use speedy::{Context, Readable, Reader, Writable, Writer};
#[derive(Debug, PartialEq, Eq)]
pub struct VendorId_t {
pub vendorId: [u8; 2],
}
impl VendorId_t {
pub const VENDOR_UNKNOWN: VendorId_t = VendorId_t {
vendorId: [0x00; 2],
};
}
impl Default for VendorId_t {
fn default() -> Self {
... | true |
17ceec7689989b98423d265571e0780d1dbec712 | Rust | sidvishnoi/leetcode-rust | /0451-sort-characters-by-frequency.rs | UTF-8 | 948 | 3.53125 | 4 | [] | no_license | struct Solution;
impl Solution {
pub fn frequency_sort(s: String) -> String {
let mut counts = std::collections::HashMap::new();
let len = s.len();
let mut buckets = vec![Vec::new(); len + 1];
for ch in s.into_bytes() {
*counts.entry(ch).or_insert(0) += 1;
}
... | true |
0bd887086245d106b3aac481441f1d993b5f9006 | Rust | ShirleyChung/rust | /readf/src/main.rs | UTF-8 | 727 | 3.234375 | 3 | [] | no_license | //use std::error::Error;
use std::fs::File;
use std::io::prelude::*;
use std::path::Path;
use std::env;
fn main() {
let filename: &str;
let args: Vec<String> = env::args().collect();
if args.len() > 1 {
filename = &args[1];
} else {
filename = "./test.txt";
}
let fpath = Path::n... | true |
7bcc916137a94e34ae370c61131058b8f0c9ef04 | Rust | m-kann0/atcoder-rust | /examples/abc089_d.rs | UTF-8 | 2,198 | 3.515625 | 4 | [] | no_license | use std::io::Read;
fn main() {
let mut buf = String::new();
std::io::stdin().read_to_string(&mut buf).unwrap();
let answer = solve(&buf);
println!("{}", answer);
}
fn solve(input: &str) -> String {
let mut iterator = input.split_whitespace();
let h: usize = iterator.next().unwrap().parse().... | true |
398edb29e6193013f35cca48707e5f3a5a2be3f3 | Rust | lenscas/silver_animation | /src/contained.rs | UTF-8 | 2,291 | 2.890625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use crate::{AnimationShape, BasicAnimation, ContainedAnimation, EditableState, Resetable};
use quicksilver::geom::Vector;
use std::marker::PhantomData;
/// The struct used to turn a BasicAnimation into a ContainedAnimation
pub struct BasicAnimationContainer<Animation, Size, Combined>
where
Animation: BasicAnimatio... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.