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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
2281cc89d95f8b4995a09747b7e0eef6cd5d1eea | Rust | Anton-4/actix | /src/address/envelope.rs | UTF-8 | 2,982 | 2.796875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::marker::PhantomData;
use futures::sync::oneshot::Sender;
use actor::{Actor, AsyncContext};
use context::Context;
use handler::{Handler, ResponseType, MessageResult, MessageResponse};
/// Converter trait, packs message to suitable envelope
pub trait ToEnvelope<A: Actor> {
/// Pack message into suitable e... | true |
ea222398c933f412f51d076f79d8a39fcfb7a65a | Rust | icedland/iced | /src/rust/iced-x86-lua/src/blk_enc.rs | UTF-8 | 3,072 | 2.671875 | 3 | [
"MIT"
] | permissive | // SPDX-License-Identifier: MIT
// Copyright (C) 2018-present iced project and contributors
use crate::instr::Instruction;
use loona::prelude::*;
lua_struct_module! { luaopen_iced_x86_BlockEncoder : BlockEncoder }
lua_impl_userdata! { BlockEncoder }
/// Encodes instructions
///
/// `Encoder` can only encode one inst... | true |
e7ae40ca2a2b7478c1b75fb67b654264a0d5a399 | Rust | inda20plusplus/mvid-chess | /lib/src/board/test_move_piece.rs | UTF-8 | 3,172 | 3.25 | 3 | [] | no_license | use super::tests::create_test_board;
use super::{Color, Kind, Piece, Point};
use std::collections::HashMap;
#[test]
fn test_move_to_empty_and_sets_has_moved() {
let mut board = create_test_board(vec![(Point(1, 1), Piece::new(Color::White, Kind::Rook))]);
let result: bool = board.move_piece(Point(1, 1), Point(... | true |
a695c2a907bfc1a26e6044e2f6da37788a069b12 | Rust | pontus/slasktest | /8/2.rs | UTF-8 | 3,996 | 2.953125 | 3 | [
"MIT"
] | permissive | use std::collections::HashSet;
use std::fs::File;
use std::io::{self, BufRead};
fn main() {
let mut sum = 0 as u32;
let lines = io::BufReader::new(File::open("input.txt").unwrap()).lines();
let _uniquelengths = Vec::from([2, 7, 4, 3]);
for l in lines {
let line = l.unwrap();
let indat... | true |
74a980165b1788dd36c22983a59a7d524ed2ffb9 | Rust | isgasho/cov-mark | /tests/smoke.rs | UTF-8 | 630 | 2.578125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | fn safe_divide(dividend: u32, divisor: u32) -> u32 {
if divisor == 0 {
cov_mark::hit!(save_divide_zero);
return 0;
}
dividend / divisor
}
#[test]
fn test_safe_divide_by_zero() {
cov_mark::check!(save_divide_zero);
assert_eq!(safe_divide(92, 0), 0);
}
struct CoveredDropper;
impl Dro... | true |
8cc0824c2b6c2038c4758a0f9a0f06e561368722 | Rust | taronaldinho/hello_rust | /bitonic_soter/src/second.rs | UTF-8 | 4,971 | 3.65625 | 4 | [] | no_license | // ジェネリクスに対応した実装。
// lib.rs から SortOrder 列挙型を読み込む。
use super::SortOrder;
// pub 修飾子でモジュール (このファイル) 外から呼び出し可能となる。
// 型パラメータを <T> で導入する。ただし、大小比較ができるものに型を制限するために、
// <T: Ord> としてトレイト境界に Ord を指定する。
// 引数は可変な Ord を持つ何らかの型の値からなるスライス (配列) の参照と、SortOrder 列挙型。
// 戻り値は、Result 型。関数成功時はユニット型 ()、エラーの場合は String 型となる。
pub fn sort<T... | true |
523ed8bfcb660bb30454a2ea17000791d93d9a89 | Rust | TChatzigiannakis/rusty_sms | /src/vm/instructions/jump.rs | UTF-8 | 1,319 | 2.875 | 3 | [
"MIT"
] | permissive | use crate::vm::cpu::alu;
use crate::vm::cpu::state::State;
use crate::vm::machine::Machine;
impl Machine {
pub(crate) fn jump(&mut self, condition: fn(&State) -> bool) {
let destination = self.next_word();
if condition(&self.cpu.state) {
self.cpu.goto(destination);
}
sel... | true |
1b08f2a32b990464a8f94988713837b9c8717877 | Rust | IThawk/rust-project | /rust-master/src/test/run-pass/const-int-rotate.rs | UTF-8 | 228 | 3.09375 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | const LEFT: u32 = 0x10000b3u32.rotate_left(8);
const RIGHT: u32 = 0xb301u32.rotate_right(8);
fn ident<T>(ident: T) -> T {
ident
}
fn main() {
assert_eq!(LEFT, ident(0xb301));
assert_eq!(RIGHT, ident(0x10000b3));
}
| true |
583fb91f2e9363c87cee2ddcfc0e4501d50dec02 | Rust | Mohammed-Kashem/zenith | /src/game/collision.rs | UTF-8 | 5,950 | 2.671875 | 3 | [
"MIT"
] | permissive | use bevy::prelude::*;
use crate::game::bullet::{Bullet, Damage};
use crate::game::enemy::{Enemy, EnemyFaction, Health};
use crate::game::player::{InvulnTimer, Player, PlayerFaction};
use crate::game::starfield::Star;
use crate::game::{GameState, WindowSize};
pub struct CollisionPlugin;
impl Plugin for CollisionPlugi... | true |
6db07cba8e07162f08a5ddb95ef42c7be9c7da28 | Rust | CredibleOpossum/duplicate_line_remover | /src/main.rs | UTF-8 | 2,519 | 3.25 | 3 | [] | no_license | use std::collections::HashSet;
use std::env;
use std::fs::File;
use std::io::{self, BufRead, BufReader, Write};
fn deduplicate_file(input_path: &str, output_path: &str, executable: &str) {
let input_file = File::open(input_path);
let input_file = match input_file {
Ok(file) => file,
Err(error) ... | true |
bfd3648fdd9cdba773ac4dcc6670cfc46cbbac98 | Rust | magnetardev/plume | /src/project.rs | UTF-8 | 715 | 2.953125 | 3 | [] | no_license | use serde::{Deserialize, Serialize};
use std::fs;
#[derive(Debug, Serialize, Deserialize)]
pub struct Project {
pub name: String,
pub version: String,
pub authors: Option<Vec<String>>,
pub description: Option<String>,
pub kind: String,
pub entry: String,
}
impl Project {
pub fn new() -> Self {
match... | true |
949dc32ea160f2cd8f7766fc7cbc15c97111ed40 | Rust | patrickbreen/demos | /pong/src/main.rs | UTF-8 | 2,235 | 2.515625 | 3 | [] | no_license | extern crate juggernaut;
extern crate piston;
extern crate graphics;
extern crate glutin_window;
extern crate opengl_graphics;
extern crate rand;
mod agent;
mod env;
use agent::Agent;
use env::Env;
fn main() {
let mut env = Env::init();
let mut agent = Agent::create();
for episode in 0..100 {
... | true |
1d8ebec0b2e9aa2f3d97f9a26e981a45415970d5 | Rust | yadavalu/KRust | /vga/src/print.rs | UTF-8 | 1,415 | 2.546875 | 3 | [] | no_license | use core::fmt;
use crate::buffer::{Buffer, BUFFERHEIGHT};
use crate::colours::{Colours, ColourCode};
use crate::writer::{Writer};
pub fn KRustWriter() -> Writer {
//use core::fmt::Write;
let writer = Writer {
column_pos: BUFFERHEIGHT,
colour_code: ColourCode::new(Colours::White, Colours::Black... | true |
8409483bb3b238fb5396a080b997f7bc1d5f2fee | Rust | hamza1311/tower-http | /tower-http/src/trace/on_response.rs | UTF-8 | 9,090 | 3 | 3 | [
"MIT"
] | permissive | use super::DEFAULT_MESSAGE_LEVEL;
use crate::LatencyUnit;
use http::Response;
use std::time::Duration;
use tracing::Level;
use tracing::Span;
/// Trait used to tell [`Trace`] what to do when a response has been produced.
///
/// See the [module docs](../trace/index.html#on_response) for details on exactly when the
///... | true |
7d97f3a0adc475619ba06b45d02951e55a5f7ae6 | Rust | hisland/my-learn | /rust-programming-2/05-common-collection/36-String-store-utf8-byte-as-vec-u8.rs | UTF-8 | 180 | 2.890625 | 3 | [] | no_license | fn main() {
// 按 utf8 存储的数据
let s1 = String::from("halo");
let s2 = String::from("你");
println!("{:?}", s1.len());
println!("{:?}", s2.len());
}
| true |
dd0db1585951d9bf88639182f8d1e3dcbd37bcf1 | Rust | zayenz/advent-of-code-2018 | /day15/tests/samples.rs | UTF-8 | 1,907 | 2.6875 | 3 | [
"MIT"
] | permissive | use assert_cli;
#[test]
fn sample1_1() {
assert_cli::Assert::main_binary()
.stdin(
"#######
#.G...#
#...EG#
#.#.#G#
#..G#E#
#.....#
#######",
)
// .stdout()
// .is("27730")
.unwrap();
}
#[test]
fn sample1_2() {
assert_cli::Assert::main_binary()... | true |
0c2eb0f224d3fedbb2b5265a2e730942047c3cd2 | Rust | cyrex562/abstreet | /game/src/common/plot.rs | UTF-8 | 5,535 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | use crate::render::OUTLINE_THICKNESS;
use abstutil::prettyprint_usize;
use ezgui::{Color, DrawBoth, EventCtx, GeomBatch, GfxCtx, Line, ScreenPt, ScreenRectangle, Text};
use geom::{Duration, Polygon, Pt2D};
// The X axis is Durations, with positive meaning "faster" (considered good) and negative "slower"
pub struct His... | true |
f91880fa640e70dfb8543cd532e7a4fe7ee5e302 | Rust | Daniel-Runge/project-euler | /src/problems/p006.rs | UTF-8 | 361 | 3.625 | 4 | [] | no_license | /// Problem 6
/// The difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.
/// https://projecteuler.net/problem=6
pub fn solve() -> usize {
let mut sum_of_squares = 0;
let mut sum = 0;
for i in 0..=100 {
sum_of_squares += i*i;
sum += ... | true |
e896fabb24b658b4d128e62cda4e064538c53f93 | Rust | xi-editor/xi-editor | /rust/core-lib/src/edit_ops.rs | UTF-8 | 15,558 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2020 The xi-editor Authors.
//
// 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 ag... | true |
6ae9b48fbe2c1bd87885d8d064b02053f1f360fe | Rust | AndrewKvalheim/rust-exercises | /diffie-hellman/src/lib.rs | UTF-8 | 350 | 2.5625 | 3 | [
"MIT"
] | permissive | mod utilities;
use rand::prelude::*;
use utilities::modular_pow;
pub fn private_key(p: u64) -> u64 {
thread_rng().gen_range(2, p)
}
pub fn public_key(p: u64, g: u64, private_key: u64) -> u64 {
modular_pow(g, private_key, p)
}
pub fn secret(p: u64, public_key: u64, private_key: u64) -> u64 {
modular_pow(... | true |
5e9674d574bb7f58cba5a5a2777456fb1e79e83b | Rust | matthewljsmith/tracing-layer-slack | /src/filters.rs | UTF-8 | 3,850 | 3.328125 | 3 | [
"Apache-2.0"
] | permissive | use core::option::Option;
use core::option::Option::Some;
use core::result::Result;
use core::result::Result::{Err, Ok};
use std::io::Error;
use regex::Regex;
/// EventFilters describes two optional lists of regular expressions used to filter events.
///
/// If provided, each expression is used in either negatively (... | true |
9cb39644513800a40af598939de491e263e47f33 | Rust | christopherferreira19/multitap | /multitap-core/src/error.rs | UTF-8 | 615 | 2.78125 | 3 | [] | no_license | use std::{fmt, error as std_error};
pub type Result<T, E = Error> = std::result::Result<T, E>;
pub trait GenericError
where
Self: std_error::Error + Send + Sync + 'static,
{}
impl<T> GenericError for T
where
T: std_error::Error + Send + Sync + 'static,
{}
#[derive(Debug)]
pub struct Error(Box<dyn GenericErr... | true |
2b88ce6a1ff29aff4f29581650f4f229c0e68b60 | Rust | jbradberry/advent-of-code | /2022/day08-2/src/main.rs | UTF-8 | 1,900 | 3.046875 | 3 | [] | no_license | use std::io;
use std::io::prelude::*;
fn read() -> Vec<Vec<i8>> {
let stdin = io::stdin();
stdin.lock().lines()
.map(|x| {
let line = x.unwrap();
line.chars().map(|c| c.to_digit(10).unwrap() as i8).collect()
})
.collect()
}
fn visible(trees: &Vec<Vec<i8>>) ->... | true |
cca9ab256ebec2d20408a048355a02e5bddd9cda | Rust | SCAII/Sky-RTS | /backend/src/engine/systems/collision.rs | UTF-8 | 3,848 | 2.71875 | 3 | [
"BSD-3-Clause"
] | permissive | use specs::{Entity, FetchMut, ReadStorage, System, WriteStorage};
use engine::resources::SkyCollisionWorld;
use engine::components::{Attack, AttackSensor, CollisionHandle, FactionId, Move, MovedFlag, Pos};
#[derive(SystemData)]
pub struct CollisionSystemData<'a> {
moved: ReadStorage<'a, MovedFlag>,
pos: ReadSt... | true |
3638aa3600e731ecaf8def7c9130269143048b22 | Rust | andrewcharlton/advent-of-code | /2019/day01/src/main.rs | UTF-8 | 1,172 | 3.53125 | 4 | [
"MIT"
] | permissive | use std::cmp::max;
use std::fs;
fn main() {
let masses: Vec<i64> = fs::read_to_string("input")
.expect("couldn't open file")
.lines()
.map(|line| line.parse().unwrap())
.collect();
let fuel_sum: i64 = masses.iter().map(|&mass| fuel_needed(mass)).sum();
println!("Part one: {... | true |
4c4c781b8e7263b96dad546fcdd69f245e8db76e | Rust | c410-f3r/mazth | /lib/bound_sphere.rs | UTF-8 | 918 | 2.53125 | 3 | [
"BSD-2-Clause"
] | permissive | use std::f64;
use i_bound::BoundType;
use i_bound::IBound;
use i_shape::ShapeType;
#[derive(Debug)]
#[derive(Clone)]
pub struct BoundSphere {
//todo
}
impl BoundSphere {
pub fn init( _shape_type: ShapeType, _vals: &[f64] ) -> BoundSphere {
BoundSphere {}
}
}
impl IBound for BoundSphere {
fn ... | true |
c2455a4f6dd92abd1af16ea616cc749a8f6c99ba | Rust | riscv-rust/gd32vf103xx-hal | /src/backup_domain.rs | UTF-8 | 1,282 | 2.765625 | 3 | [
"ISC"
] | permissive | /*!
Registers that are not reset as long as Vbat or Vdd has power.
The registers retain their values during wakes from standby mode or system resets. They also
retain their value when Vdd is switched off as long as V_BAT is powered.
The backup domain also contains tamper protection and writes to it must be ena... | true |
c494867baff6bd36fe1d7a802bfb1bc13fb7683c | Rust | verrchu/keywords | /api/keywords_cli/src/command.rs | UTF-8 | 1,342 | 3.09375 | 3 | [] | no_license | use clap::{App, AppSettings, Arg, ArgMatches};
pub fn run() {
let matches = App::new("keywords")
.setting(AppSettings::ArgRequiredElseHelp)
.setting(AppSettings::PropagateVersion)
.subcommand(
App::new("search")
.arg(
Arg::new("languages")
... | true |
74343ab6a2d01fbc499310b33766aeaaea756233 | Rust | NyxCode/word-cloud-generator | /generator/src/io.rs | UTF-8 | 4,137 | 2.75 | 3 | [] | no_license | use std::io::{BufRead, BufReader};
use std::collections::{HashMap, HashSet};
use regex::Regex;
use rusttype::Font;
use font_loader::system_fonts;
use std::fs::File;
use std::fs::read_to_string;
use crate::log_time;
use crate::cli::CLIOptions;
use crate::wordcloud::WordCloud;
use std::path::PathBuf;
use cra... | true |
3e5a4f5e82f51dd1a770ec9817e698864f4ef31d | Rust | esovm/Elm-interpreter | /src/tokenizer/token_parser.rs | UTF-8 | 7,225 | 2.6875 | 3 | [
"MIT"
] | permissive | use nom::*;
use ast::Int;
use tokenizer::Token::*;
use tokenizer::Token;
use util::*;
// Tokenizing is done with the crate nom, except error handling and skipping spaces, comments and indentation
named!(lower<char>, one_of!("abcdefghijklmnopqrstuvwxyz"));
named!(upper<char>, one_of!("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
... | true |
03789a8fdd04e895e3d5f63b970e20da341afab1 | Rust | domodwyer/pmc-rs | /pmc-rs/src/counter.rs | UTF-8 | 10,410 | 2.609375 | 3 | [
"BSD-3-Clause"
] | permissive | use std::ffi::CString;
use std::io;
use std::sync::{Mutex, Once};
#[cfg(target_os = "freebsd")]
use libc::EDOOFUS;
#[cfg(target_os = "freebsd")]
use pmc_sys::{
pmc_allocate, pmc_attach, pmc_detach, pmc_id_t, pmc_init, pmc_mode_PMC_MODE_SC,
pmc_mode_PMC_MODE_TC, pmc_read, pmc_release, pmc_rw, pmc_start, pmc_sto... | true |
2108886658450cb040bee202248b58bdce3a419c | Rust | rumblesan/dass | /src/lexer.rs | UTF-8 | 2,310 | 2.90625 | 3 | [
"BSD-2-Clause",
"BSD-3-Clause"
] | permissive | use std::fmt::Display;
use super::error::ParserError;
use super::position_tracker::PositionTracker;
use super::tokens::{TokenData, TokenMatcher};
pub struct DassLexerBuilder<T>
where
T: Clone + Display,
{
matchers: Vec<TokenMatcher<T>>,
}
impl<T> DassLexerBuilder<T>
where
T: Clone + Display,
{
pub fn... | true |
16615d8dda2f2a1738d2a80fcc91d4017728ab0b | Rust | ptrgags/chaos-game-3d | /src/macros.rs | UTF-8 | 281 | 3.53125 | 4 | [
"Apache-2.0"
] | permissive | /// to_box(Trait)
/// A lot of my types need to be boxed, so this macro defines a method
/// to_box() that wraps a struct in a Box<dyn Trait>.
macro_rules! to_box {
($type:ident) => {
pub fn to_box(self) -> Box<dyn $type> {
Box::new(self)
}
}
}
| true |
52908c6297c56d4da6cd70e4e2f559e24d63206d | Rust | davidMcneil/mnist | /src/tests.rs | UTF-8 | 6,357 | 2.8125 | 3 | [] | no_license | #![cfg(test)]
use super::*;
use ndarray::prelude::*;
#[test]
fn test_example() {
// Deconstruct the returned Mnist struct.
let Mnist {
trn_img,
trn_lbl,
tst_img,
tst_lbl,
..
} = MnistBuilder::new()
.label_format_digit()
.training_set_length(50_000)
... | true |
d343f8e4841c425c1ba8cfdb874a71a43504db34 | Rust | 9uapaw/fordragon-backend | /server/src/common/quad_tree.rs | UTF-8 | 12,228 | 2.84375 | 3 | [] | no_license | #![feature(drain_filter)]
use crate::game::location::pos::{Area, Position, Positionable};
use std::borrow::Borrow;
use std::collections::HashMap;
use std::slice::{Iter, IterMut};
use std::sync::atomic::AtomicPtr;
#[derive(Debug)]
pub struct QuadNode<T>
where
T: Positionable,
{
area: Area,
children: Vec<us... | true |
d24e868777ed747d3e8570400c8856a02c980c50 | Rust | flappyBug/leetcode-rs | /src/p0717.rs | UTF-8 | 813 | 3.515625 | 4 | [] | no_license | pub struct Solution;
impl Solution {
pub fn is_one_bit_character(bits: Vec<i32>) -> bool {
let mut unpair = false;
let mut zero = true;
for &bit in bits.iter() {
match (unpair, bit) {
(true, _) => unpair = false,
(false, 0) => zero = true,
... | true |
061db9911fad21bb1892e752f410f7322044e41a | Rust | KS-Japan/introduction-to-rust-programming-language | /day3/src/main.rs | UTF-8 | 1,752 | 3.828125 | 4 | [] | no_license |
//高階関数書いた偶数二乗合計
//isize = i32 int型で入れてint型で返す
//関数宣言時、戻り値には変数名を書かないが、矢印を用いて返り値の型を定義する
//返り値はreturnで定義しなくても、最後の値が返り値となる
fn square_sum(n: isize)->isize{
//0からnまでの区間をとる。
(0..n)
//リストやイテレータを返してTrueとなるものだけを返す
// n=5の時, [2,4]のみiに入る
.filter(|i| i % 2 == 0)
// 要素を絶対値に変換
//0からと定義しているため意味はないが、-1が入... | true |
30dcc57301159a6ced9e1bcb2f24fe570e425d1b | Rust | hbragge/luonto | /rust/stalker/src/enemy.rs | UTF-8 | 2,966 | 2.640625 | 3 | [] | no_license | use crate::common::*;
use crate::drawing::draw_block;
use piston_window::types::Color;
use piston_window::Context;
use piston_window::G2d;
use soloud::*;
const ENEMY_COLOR: Color = [0.8, 0.25, 0.1, 1.0];
static REACT1: &[u8] = include_bytes!("../resources/react1.wav");
static REACT2: &[u8] = include_bytes!("../resour... | true |
b0263838e249d5685a8bf636ba9a07c7f25b05b5 | Rust | presciense/actix-mqtt | /codec/src/packet.rs | UTF-8 | 7,275 | 2.890625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use bytes::Bytes;
use bytestring::ByteString;
use crate::proto::{Protocol, QoS};
#[repr(u8)]
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
/// Connect Return Code
pub enum ConnectCode {
/// Connection accepted
ConnectionAccepted = 0,
/// Connection Refused, unacceptable protocol version
UnacceptablePro... | true |
8c09875d2c2ed1ea4f5deccc738d3c7a2c25316e | Rust | sector-f/pong-rs | /src/ball.rs | UTF-8 | 2,947 | 2.90625 | 3 | [] | no_license | // use ncollide_geometry::bounding_volume::AABB;
// use ncollide_geometry::query::ray_internal::Ray;
// use nalgebra::{Point2, Vector2};
use nalgebra::Point2;
use hitbox::Hitbox;
pub struct Ball {
pub center: Point2<f64>,
// status: BallStatus,
pub visible: bool,
pub size: u32,
pub dx: f64,
pub... | true |
6688b5a8bcca88bfc24472daac96ccb618d2ec25 | Rust | billyrayvalentine/rust-megadrive-cart-info | /src/main.rs | UTF-8 | 2,336 | 2.765625 | 3 | [
"MIT"
] | permissive | // commandline tool for megadrive-cart-info
use megadrive_cart_info::megadrive::MegaDriveROMHeader;
use std::env;
use std::path::Path;
use std::process;
const VERSION: &'static str = env!("CARGO_PKG_VERSION");
fn main() {
fn print_usage() {
println!("usage: megadrive_cart_info [-hV] <filename>");
... | true |
6454a685bd6f555494df4d63e76787e10245fbd6 | Rust | marius851000/farctool | /src/main.rs | UTF-8 | 7,798 | 2.8125 | 3 | [] | no_license | use anyhow::{bail, Context, Result};
use clap::Clap;
use env_logger;
use log::{debug, info};
use pmd_farc::{hash_name, message_dehash, Farc, FarcWriter, FileHashType};
use std::fs::File;
use std::path::PathBuf;
use std::{
fs::create_dir_all,
io::{Read, Write},
};
#[derive(Clap)]
/// tool for reading farc file ... | true |
72e090fdeb6a05536ada5431771292cfcce75fab | Rust | utwyko/dodax-prices | /src/main.rs | UTF-8 | 1,230 | 2.828125 | 3 | [] | no_license | use clap::{App, Arg};
use scraper::{Html, Selector};
fn main() {
let matches = App::new("dodax")
.version("0.0.1")
.author("Wyko Rijnsburger <utwyko@gmail.com")
.arg(Arg::with_name("Query")
.required(true)
.takes_value(true)
.index(1)
.help("Q... | true |
d364ec4912917f00063ad4ca9c63ee42fe53ceed | Rust | cronosun/liquesco-rust | /gen-doc/src/types/common.rs | UTF-8 | 5,973 | 3.125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | // Common functions
use liquesco_common::decimal::Decimal;
use num_format::{Locale, ToFormattedString};
use std::convert::TryFrom;
use std::fmt::Display;
use std::num::FpCategory;
pub(crate) struct Common;
const U64_U8_MAX: u64 = std::u8::MAX as u64;
const U64_U16_MAX: u64 = std::u16::MAX as u64;
const U64_U32_MAX: ... | true |
65845213f14cf72222485d565948b562bb119485 | Rust | sgreenlay/aoc-2019 | /src/day18.rs | UTF-8 | 9,456 | 3.03125 | 3 | [] | no_license | use std::fs;
use std::collections::HashMap;
use std::collections::HashSet;
fn load_input(filename: String) -> Vec<Vec<char>> {
fs::read_to_string(filename)
.expect("Can't read file")
.split('\n')
.filter_map(|s: &str| {
if s.len() == 0 {
None
} else ... | true |
21491a484ac44115855ffa5f44351eff0245b2a9 | Rust | ducaale/xh | /src/printer.rs | UTF-8 | 31,670 | 2.5625 | 3 | [
"MIT"
] | permissive | use std::borrow::Cow;
use std::io::{self, BufRead, BufReader, Read, Write};
use std::time::Instant;
use encoding_rs::Encoding;
use encoding_rs_io::DecodeReaderBytesBuilder;
use mime::Mime;
use reqwest::blocking::{Body, Request, Response};
use reqwest::cookie::CookieStore;
use reqwest::header::{
HeaderMap, HeaderNa... | true |
fb9b81e7d8d6b3a250b47b47547efe74e01d6a9c | Rust | pearzl/leetcode_rust | /src/answer/q0075_sort_colors.rs | UTF-8 | 3,527 | 3.484375 | 3 | [] | no_license | // q0075_sort_colors
struct Solution;
impl Solution {
pub fn sort_colors(nums: &mut Vec<i32>) {
if nums.is_empty() {
return;
}
let mut p1 = 0;
let mut p2 = nums.len() - 1;
let mut next_0 = p1;
let mut next_2 = p2;
while p1 <= p2 {
// ... | true |
05f2469f314d82ffb5a6aeffe1f33e4fd1de7c6c | Rust | teruuuuuu/kyoupro | /rust/src/atcoder/beginner/q116/c.rs | UTF-8 | 643 | 2.921875 | 3 | [] | no_license | use std;
pub fn main() {
fn read<T: std::str::FromStr>() -> T {
let mut s = String::new();
std::io::stdin().read_line(&mut s).ok();
s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collec... | true |
f4cc9ae0157641b26af0e800d948b76b2f196e52 | Rust | bytebuddha/SipClient | /core/src/config/var_key.rs | UTF-8 | 723 | 2.859375 | 3 | [] | no_license | use std::fmt;
use std::str::FromStr;
use serde::{ Serialize, Deserialize };
use crate::core::NirahError;
#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize)]
pub struct VariableKey(String);
impl VariableKey {
pub fn new<S: Into<String>>(string: S) -> VariableKey {
VariableKey(string.into... | true |
d3e2e7616976868a036bd38193395a6639a236c9 | Rust | mesalock-linux/crates-sgx | /vendor/block-buffer/src/lib.rs | UTF-8 | 6,766 | 3.015625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | #![no_std]
pub extern crate byteorder;
pub extern crate block_padding;
pub extern crate generic_array;
extern crate byte_tools;
use byteorder::{ByteOrder, BE};
use byte_tools::zero;
use block_padding::{Padding, PadError};
use generic_array::{GenericArray, ArrayLength};
//use core::slice;
/// Buffer for block processi... | true |
e22fd5bcbd6478464a7949a57ceb3aaf6d487fe5 | Rust | dainslef/RustPractice | /src/leetcode.rs | UTF-8 | 11,042 | 3.921875 | 4 | [
"BSD-3-Clause"
] | permissive | //! The common data structure definition for leetcode problems.
/**
The definition of `ListNode`, used by many problems.
*/
#[derive(PartialEq, Eq, Debug)]
pub(crate) struct ListNode {
val: i32,
next: Option<Box<Self>>,
}
impl ListNode {
#[inline]
fn new(val: i32) -> Self {
Self { next: None, val }
}
}
... | true |
ebdd6497b2f80037958892a612347171d6bcc9c6 | Rust | Dentosal/rust_os | /src/memory/allocators/dma_allocator.rs | UTF-8 | 1,939 | 2.890625 | 3 | [
"MIT"
] | permissive | //! DMA / VirtIO memory buffers (requiring "low" memory)
use spin::Mutex;
use x86_64::structures::paging as pg;
use x86_64::{PhysAddr, VirtAddr};
use super::super::constants::{DMA_MEMORY_SIZE, DMA_MEMORY_START};
const DMA_BLOCK_SIZE: usize = 0x1000;
const DMA_BLOCKS: usize = round_up_block(DMA_MEMORY_SIZE as usize);... | true |
5159fb9a225d742c0bca61465d41f05c5ae3c3fd | Rust | KlotzAndrew/concur | /src/mv_register.rs | UTF-8 | 1,052 | 3.265625 | 3 | [] | no_license | use std::collections::HashMap;
#[derive(Clone)]
pub struct MVRegister {
elements: HashMap<String, Element>
}
#[derive(Clone)]
struct Element {
id: String,
pub value: String,
version: u32
}
impl Default for MVRegister {
fn default() -> Self {
MVRegister::new()
}
}
impl MVRegister {
pub fn new() -> ... | true |
245524d4b72c97003be03ec0f51b6c48148b8a99 | Rust | kdy1/deno_lint | /src/test_util.rs | UTF-8 | 2,402 | 2.5625 | 3 | [
"MIT"
] | permissive | // Copyright 2020 the Deno authors. All rights reserved. MIT license.
use crate::diagnostic::LintDiagnostic;
use crate::linter::LinterBuilder;
use crate::rules::LintRule;
use crate::swc_util;
fn lint(rule: Box<dyn LintRule>, source: &str) -> Vec<LintDiagnostic> {
let mut linter = LinterBuilder::default()
.lint_... | true |
be8347bde7b35e8b8130ad0bf3c7122a68e91f3f | Rust | CodeBreaker444/rust_basics-snippets-cheatsheet | /some_basics/src/main.rs | UTF-8 | 930 | 3.421875 | 3 | [] | no_license | mod functions;
fn main() {
let x=0.2;//floating points
let y:f32=000.02;
println!("{},{}",x,y);
//numbers can be decimals, hex, binary, octals, byte
let t=true;//boolean type
let f:bool=false;
println!("{},{}",t,f);
let c='h';//character type
let ch:char='i';
let e='😁';//suppo... | true |
5da1aa21d8d4644ca639897cf2e7b4025ec8f239 | Rust | dvdsk/yarte | /yarte/src/lib.rs | UTF-8 | 4,612 | 3.421875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Yarte stands for **Y**et **A**nother **R**ust **T**emplate **E**ngine,
//! is the fastest template engine. Uses a Handlebars-like syntax,
//! well known and intuitive for most developers. Yarte is an optimized, and easy-to-use
//! rust crate, can create logic around their templates using conditionals, loops,
//! ru... | true |
11d267908e34e6e2b41bcfebef3008ef922be605 | Rust | zeroclassic/zeroclassic-vendored-crates | /vendored-sources/bitvec/src/array.rs | UTF-8 | 7,451 | 3.375 | 3 | [] | no_license | /*! A fixed-size region viewed as individual bits, corresponding to `[bool]`.
You can read the language’s [array fundamental documentation][std] here.
This module defines the [`BitArray`] immediate type, and its associated support
code.
`BitArray` has little behavior or properties in its own right. It serves solely
... | true |
0f63ac42318a7feab8d62d3484a40403b776f81f | Rust | csssuf/coreos-metadata | /src/retry/client.rs | UTF-8 | 6,464 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2017 CoreOS, Inc.
//
// 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... | true |
567c61717dbafff5255a73cd3dcab942aac4b54f | Rust | amar-laksh/ros2soc | /src/lib.rs | UTF-8 | 4,351 | 2.734375 | 3 | [] | no_license | extern crate clap;
use std::env;
use std::io::stdin;
use std::path::Path;
use std::process::*;
use std::result::Result;
pub struct Ros2soc {
pub package: String,
pub destination: String,
pub ip: String,
pub username: String,
pub ros2_dir: String,
pub package_dir: String,
pub level: u8,
... | true |
3a10c23edb22fccbe2481dcf6890cd9dd781d34c | Rust | garfieldnate/ray_tracer_challenge | /lib/src/pattern/rings.rs | UTF-8 | 1,563 | 3.5 | 4 | [
"MIT"
] | permissive | use crate::color::Color;
use crate::constants::black;
use crate::constants::white;
use crate::pattern::pattern::BasePattern;
use crate::pattern::pattern::Pattern;
use crate::tuple::Tuple;
#[derive(Clone, Debug, PartialEq)]
pub struct Rings {
base: BasePattern,
a: Color,
b: Color,
}
impl Rings {
pub fn... | true |
5dea947c9033354cf5cf763a73ad09b3cb4c5029 | Rust | dgoetsch/advent-of-code-2020 | /src/day10.rs | UTF-8 | 4,934 | 3.109375 | 3 | [] | no_license | use std::collections::HashMap;
use super::lines;
struct PathFinder {
cache: HashMap<usize, usize>,
count: usize
}
impl PathFinder {
fn count_valid_combinations(&mut self, adapters: Vec<usize>) -> usize {
self.count = self.count + 1;
if adapters.len() == 1 {
return 1;
} ... | true |
f28dfea692916784bf57fdb99bdbaba37668d0c1 | Rust | mkut/ibara_tools | /rs/ibara_parser/src/parser/general/ignored.rs | UTF-8 | 902 | 2.625 | 3 | [] | no_license | extern crate scraper;
use scraper::Node;
use ego_tree::iter::Children;
use crate::data::traceable::Traceable;
use crate::parser::{text};
/*
* ELEMENT_NAME
* => element_name
*/
pub fn parse(element_name: &str) -> impl Fn(&mut Traceable<Children<Node>>) -> Result<(), String> + '_ {
move |cursor| {
text::sk... | true |
78d328dff7e891c0abae11650882362a27a891fd | Rust | etvanlieshout/rust_learning | /scalar_types_tests/temp_converter/src/main.rs | UTF-8 | 756 | 3.453125 | 3 | [] | no_license | use std::io;
fn main() {
println!("Temp Converter");
println!("Enter 1 for F to C or 2 for C to F");
let mut convert_mode = String::new();
io::stdin()
.read_line(&mut convert_mode)
.expect("Failed to read input");
let convert_mode: u32 = convert_mode.trim().parse().expect("Invalid");
println!("Enter tem... | true |
d17ffdfd5b051a5c7413dee6886f19e461f296a8 | Rust | IThawk/rust-project | /rust-master/src/test/ui/associated-type-bounds/bounds-on-assoc-in-trait.rs | UTF-8 | 892 | 2.625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-other-permissive",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // check-pass
#![feature(associated_type_bounds)]
use std::fmt::Debug;
use std::iter::Empty;
use std::ops::Range;
trait Lam<Binder> { type App; }
#[derive(Clone)]
struct L1;
impl<'a> Lam<&'a u8> for L1 { type App = u8; }
#[derive(Clone)]
struct L2;
impl<'a, 'b> Lam<&'a &'b u8> for L2 { type App = u8; }
trait Case... | true |
b9818b4c3c0ca70b97171f1f48cd3ec9a6000adb | Rust | korczis/maze-rs | /src/generator/binary.rs | UTF-8 | 1,149 | 3.109375 | 3 | [
"MIT"
] | permissive | extern crate rand;
use rand::Rng;
use super::super::types::cell::Cell;
use super::super::types::grid::Grid;
pub fn generate<T>(grid: &mut Grid<T>)
where T: Cell + Clone
{
grid.visit(|grid, cell| {
let mut cells: Vec<T> = Vec::new();
if cell.x() < (grid.x() - 1) {
cells.push(grid[... | true |
5ac13cc54b81653d03933b80f5b8817e2bb3595d | Rust | imbolc/perseus | /packages/perseus/src/shell.rs | UTF-8 | 21,232 | 2.546875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::error_pages::ErrorPageData;
use crate::errors::*;
use crate::path_prefix::get_path_prefix_client;
use crate::serve::PageData;
use crate::template::Template;
use crate::ClientTranslationsManager;
use crate::ErrorPages;
use fmterr::fmt_err;
use js_sys::Reflect;
use std::cell::RefCell;
use std::collections::Has... | true |
60023e9fda0a3fbcae5766e177c44095a94616d2 | Rust | kgtkr/procon | /atcoder/rust/arc064_c/src/main.rs | UTF-8 | 5,520 | 2.90625 | 3 | [] | no_license | extern crate core;
use std::io::{self, Read};
fn main() {
let mut input = String::new();
io::stdin().read_to_string(&mut input).unwrap();
let output = run(input.trim().to_string());
println!("{}", output);
}
#[derive(Debug, PartialEq, Clone)]
struct Vec2 {
x: f64,
y: f64,
}
#[derive(Debug, P... | true |
11267d2c383aa61f47f22d7ce090ad842f391b7b | Rust | JTPond/calcify | /src/tree/feedtree.rs | UTF-8 | 9,007 | 3.046875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::collections::HashMap;
use std::error;
use super::Collection;
use crate::utils;
use utils::{Serializable, Deserializable};
use utils::errors::CalcifyError;
use utils::io::{ToFile,FromFile};
extern crate rmp;
use rmp::encode::*;
use rmp::decode::*;
/// Tree of Collections of only a single type, which impl the... | true |
557a36cfd0ac41597522339d5789a81a5d9117f2 | Rust | leontoeides/google_maps | /src/places/place_special_day.rs | UTF-8 | 1,486 | 3.265625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! An object describing the opening hours of a place on special days or
//! holidays.
use chrono::NaiveDate;
use serde::{Deserialize, Serialize};
// -----------------------------------------------------------------------------
//
/// An object describing the opening hours of a place on special days or
/// holidays.
... | true |
e15ee1011bfb539d07d022a1a9b5c18cb5b0006d | Rust | Lucky4Luuk/minecraft-protocol | /src/packets/play_clientbound.rs | UTF-8 | 47,973 | 2.75 | 3 | [] | no_license | #[allow(unused_imports)]
use super::play_serverbound::ServerboundPacket;
use crate::nbt::NbtTag;
use crate::components::*;
use crate::ids::*;
use crate::ids::blocks;
use super::*;
#[derive(Debug, MinecraftPacketPart)]
#[discriminant(VarInt)]
pub enum ClientboundPacket<'a> {
/// Sent by the server when a vehicle or... | true |
90d4493b47aaa932ac6bf713f5334007cac2fcab | Rust | iandanforth/rust-crypto | /book/projects/loops/src/main.rs | UTF-8 | 554 | 4 | 4 | [
"MIT"
] | permissive | fn main() {
let finish = 5;
let mut count = 1;
loop {
println!("Again!");
if count >= finish {
break;
}
count += 1; // Glad this increment operator exists!
}
let mut number = 4;
while number != 0 {
println!("Remaining = {}", number);
... | true |
3d93dd1369488b0af7227a42de9fecf1b681a163 | Rust | buntine/barcoders | /src/sym/codabar.rs | UTF-8 | 5,070 | 3.375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Encoder for Codabar barcodes.
//!
//! Codabar is a simple, self-checking symbology without a standard for a checksum digit.
//!
//! Codabar is used in the USA by FedEx, some Hospitals, and photo labs.
//!
//! Barcodes of this variant should start and end with either A, B, C, or D depending on
//! the industry.
use... | true |
210541f8fbc203fac5feb643a2fca8ec647e6562 | Rust | s-tian/aoc-2017 | /day_15.rs | UTF-8 | 864 | 3 | 3 | [] | no_license | use std::fs::File;
use std::io::Read;
fn main() {
let mut f = File::open("day_15_input.txt").expect("File not found");
let mut _inp = String::new();
f.read_to_string(&mut _inp).expect("Something went wrong");
let mut _it = _inp.lines();
let mut r1: u64 = _it.nth(0).unwrap().split_whitespace().nth(4... | true |
a690edaaa96c1c8025485bbe384753ea50d9d63d | Rust | kohbis/leetcode | /algorithms/0230.kth-smallest-element-in-a-bst/solution.rs | UTF-8 | 1,096 | 3.390625 | 3 | [] | no_license | // Definition for a binary tree node.
// #[derive(Debug, PartialEq, Eq)]
// pub struct TreeNode {
// pub val: i32,
// pub left: Option<Rc<RefCell<TreeNode>>>,
// pub right: Option<Rc<RefCell<TreeNode>>>,
// }
//
// impl TreeNode {
// #[inline]
// pub fn new(val: i32) -> Self {
// TreeNode {
// val,
... | true |
f375b95babd7a6cbbca9661990a1eebfd6544181 | Rust | cjbassi/heim | /heim-disk/src/sys/windows/counters.rs | UTF-8 | 3,793 | 2.609375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::fs;
use std::path::PathBuf;
use std::os::windows::io::AsRawHandle;
use std::ffi::OsStr;
use heim_common::prelude::*;
use heim_common::units::{Time, Information};
use super::bindings::disks;
use super::bindings::volumes::Volumes;
#[derive(Debug)]
pub struct IoCounters {
volume_path: PathBuf,
read_cou... | true |
6a3dc35787f366fc41ce46bfdb1264d1f644f652 | Rust | MMKubicki/Advent-of-Code-2020 | /day05/src/main.rs | UTF-8 | 1,843 | 3.421875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | mod boarding_pass;
use std::collections::HashSet;
use std::fs;
use boarding_pass::Seat;
fn main() -> anyhow::Result<()> {
let options = common::simple_cli::Opts::get();
let content = fs::read_to_string(options.input)?;
let seats = get_seats(&content)?;
// Part 1
let highest_seat_id = seats.ite... | true |
e8f3a04a6c342ce81ae8faa7d24a8e72b96d3f0c | Rust | charypar/github-stats | /src/fetch.rs | UTF-8 | 5,472 | 2.625 | 3 | [] | no_license | use gh::client::Github;
use gh::query::Query;
use github_gql as gh;
use serde_json::Value;
pub fn fetch_teams(github: &mut Github, org: &str, team_query: &str) -> Vec<Value> {
let query = Query::new_raw(format!(
r#"{{
organization(login: "{}") {{
teams(first: 20, query: "{}") {... | true |
93830358ebf859558f0aafb397850fb52d919920 | Rust | scarvalhojr/adventofcode2020 | /day12/src/part1.rs | UTF-8 | 1,132 | 3.59375 | 4 | [
"MIT"
] | permissive | use super::*;
pub fn part1(actions: &[Action]) -> i32 {
let mut ship = Ship::default();
for action in actions {
ship.take(action);
}
ship.distance_to_origin()
}
struct Ship {
position: Coordinates,
direction: Direction,
}
impl Default for Ship {
fn default() -> Self {
Self... | true |
8cbc487b52938a34699337242932417bad312488 | Rust | AnClark/Rust_Learning_With_Guide | /functions/src/main.rs | UTF-8 | 1,135 | 4.28125 | 4 | [] | no_license | fn main() {
another_function(5, 6);
// Use a scope to assign value.
// This is a little bit similiar to instant function in Ecmascript.
//
// Expressions do not include ending semicolons.
// If you add a semicolon to the end of an expression, you turn it into a statement,
// which will t... | true |
8637789ea7e433d09cc427457aef5b75e2a40130 | Rust | Farkal/advent-of-code-2019 | /src/day8.rs | UTF-8 | 1,032 | 3.1875 | 3 | [] | no_license | use itertools::Itertools;
#[aoc_generator(day8)]
pub fn input_generator(input: &str) -> Vec<u32> {
input.chars().map(|x| x.to_digit(10).unwrap()).collect()
}
fn count_digit(x: &[u32], digit: u32) -> usize {
x.iter().filter(|&&x| x == digit).count()
}
#[aoc(day8, part1)]
fn part1(input: &[u32]) -> usize {
... | true |
1e75f96cac98b10fb211a19720ed31e0bb68158a | Rust | chef-boneyard/rs-chef-api | /chef_api/src/api_client.rs | UTF-8 | 3,538 | 2.640625 | 3 | [
"Apache-2.0"
] | permissive | use crate::credentials::Config;
use hyper::client::HttpConnector;
use hyper::Client as HyperClient;
use hyper_openssl::HttpsConnector;
use tokio_core::reactor::Core;
use failure::Error;
use serde::ser::*;
use serde_json::Value;
use std::cell::RefCell;
use std::rc::Rc;
use crate::requests::*;
/// Struct used to sta... | true |
845213802cde0755ffc2d82be816afe1a60e794c | Rust | ssolaric/cses.fi | /2. Sorting and Searching/13-room-allocation.rs | UTF-8 | 2,632 | 3.140625 | 3 | [
"MIT"
] | permissive | // Similar to https://leetcode.com/problems/meeting-rooms-ii/
use std::cmp::Reverse;
use std::collections::BinaryHeap;
use std::io;
use std::str;
fn solve<R: io::BufRead, W: io::Write>(scan: &mut Scanner<R>, out: &mut W) {
let n: usize = scan.token();
let mut events = Vec::new();
let mut rooms = vec![-1; n... | true |
6e6271d72c7c0edac04f1eb495c21a148aa1a4e9 | Rust | luccasmmg/noodles | /noodles-vcf/src/record/info.rs | UTF-8 | 5,263 | 3.421875 | 3 | [
"MIT"
] | permissive | //! VCF record information and field.
pub mod field;
pub use self::field::Field;
use std::{convert::TryFrom, error, fmt, ops::Deref, str::FromStr};
use indexmap::IndexMap;
use super::MISSING_FIELD;
const DELIMITER: char = ';';
/// VCF record information fields (`INFO`).
#[derive(Clone, Debug, Default, PartialEq)... | true |
2430c29484076d1b03c2276856ac848f2d25ea54 | Rust | jbg/rkvm | /input/src/windows/oot.rs | UTF-8 | 579 | 3.140625 | 3 | [
"MIT"
] | permissive | // Used to prevent frequent allocation in cases where one key corresponds to multiple INPUT events.
#[derive(Eq, PartialEq, Hash)]
pub enum Oot<T> {
V1([T; 1]),
V2([T; 2]),
}
impl<T> Oot<T> {
pub fn as_mut_slice(&mut self) -> &mut [T] {
match self {
Oot::V1(values) => &mut *values,
... | true |
5166caacaaeeedb920a4ff2cdb3b882a2e9234f3 | Rust | matej-g/yarchi | /src/main.rs | UTF-8 | 4,170 | 3.0625 | 3 | [
"MIT"
] | permissive | #![warn(clippy::all, rust_2018_idioms)]
#[macro_use]
extern crate clap;
use crate::interpreter::config::Config;
use crate::interpreter::Interpreter;
use clap::{App, Arg, crate_authors, crate_description};
mod interpreter;
const DEBUG_MSG: &str = "
Available actions upon pressing:
- P - prints current state of CHIP... | true |
4dc1ecc3a56217187b52608d591eb832886f94a1 | Rust | victorporof/yoga-rs | /tests/flex_direction_test.rs | UTF-8 | 14,273 | 2.734375 | 3 | [
"MIT"
] | permissive | #[macro_use]
extern crate yoga;
use yoga::{Direction, FlexDirection, Node, Undefined};
use yoga::prelude::*;
#[test]
fn test_flex_direction_column_no_height() {
let mut root = Node::new();
style!(root,
Width(100 pt)
);
let mut root_child_0 = Node::new();
style!(root_child_0,
Height(10 pt)
);
let mut ro... | true |
55cb59578e58834a58bab28093e2b37466b006db | Rust | dwbrite/dorc | /src/registration/types.rs | UTF-8 | 1,415 | 2.546875 | 3 | [] | no_license | use core::option::Option::{None, Some};
use core::option::Option;
use serde_derive::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
pub struct Service {
pub(crate) qualified_name: String,
pub(crate) working_dir: String, // defaults to /srv/www/<qualified-service-name>
pub(crate) port: u1... | true |
6471ea9ab6ef8aca8e9038b2f76b69e5362483ab | Rust | TheIndifferent/timestampname-rust | /src/timestampname/executor.rs | UTF-8 | 952 | 2.609375 | 3 | [
"BSD-3-Clause"
] | permissive | use std::fs;
use std::os::unix::fs::PermissionsExt;
use super::RenameOperation;
use super::failures::Failure;
pub fn execute_operations(operations: &Vec<RenameOperation>, dry_run: bool) -> Result<(), Failure> {
for (i, o) in operations.iter().enumerate() {
print!("\rRenaming files: {}/{}...", i + 1, opera... | true |
44136d9ddaca96bfd858c1d23ffa0939566204dd | Rust | jbradberry/sudoku.rs | /src/main.rs | UTF-8 | 6,242 | 3.125 | 3 | [] | no_license | use std::io;
use std::io::Read;
use std::char;
use std::collections::{HashMap,HashSet};
#[derive(Hash, PartialEq, Eq, Copy, Clone)]
enum Constraint {
Square { row: u8, col: u8 },
Row { row: u8, value: u8 },
Column { col: u8, value: u8 },
Block { block: u8, value: u8 },
}
#[derive(Hash, PartialEq, Eq... | true |
d1365a07a38b341caa306686baccd67d5cb9141b | Rust | norse-rs/runic | /src/filter/box_filter.rs | UTF-8 | 957 | 2.8125 | 3 | [] | no_license | use crate::{RelativeBounds, Filter, math::*};
pub struct BoxFilter {
min: f32,
max: f32,
}
impl BoxFilter {
pub fn new(min: f32, max: f32) -> Self {
BoxFilter {
min, max
}
}
}
impl Filter for BoxFilter {
fn name(&self) -> String { "Box".into() }
fn pdf(&self, x: f... | true |
e2c4bc05c93be9b42ceec960615f7a8b8a6c0e2a | Rust | memorysafety/sudo-rs | /test-framework/sudo-compliance-tests/src/sudo/timestamp/remove.rs | UTF-8 | 2,620 | 2.90625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use sudo_test::{Command, Env, User};
use crate::{Result, PASSWORD, USERNAME};
#[test]
fn is_limited_to_a_single_user() -> Result<()> {
let second_user = "ghost";
let env = Env("ALL ALL=(ALL:ALL) ALL")
.user(User(USERNAME).password(PASSWORD))
.user(User(second_user).password(PASSWORD))
... | true |
bacbd1bd57967d0cf76880390377c66667696423 | Rust | Shirataki2/competitive_submissions | /checker/src/union_find.rs | UTF-8 | 3,590 | 2.9375 | 3 | [] | no_license | #![allow(unused_macros)]
use io::IO;
use unionfind::UnionFind;
macro_rules! input { ($io:expr => $($name:ident: $t:ty),+) => { $(let $name: $t = $io.read();)* }; }
macro_rules! outln { ($io: expr) => { $io.write("\n".to_string()); }; ($io: expr => $fmt: expr) => {$io.write(format!(concat!($fmt, "\n")))}; ($io: expr => ... | true |
f23d8b00ae90e9ddd32e947fe8e1e197e1034233 | Rust | aristotle9/qt_generator-output | /qt_core/src/const_overload.rs | UTF-8 | 12,135 | 2.5625 | 3 | [] | no_license | /// C++ type: <span style='color: green;'>```QMacAutoReleasePool```</span>
#[repr(C)]
pub struct MacAutoReleasePool([u8; ::type_sizes::QT_CORE_CONST_OVERLOAD_MAC_AUTO_RELEASE_POOL]);
impl ::cpp_utils::new_uninitialized::NewUninitialized for MacAutoReleasePool {
unsafe fn new_uninitialized() -> MacAutoReleasePool {
... | true |
09ec3c404d7b5d06edb3981e5d919006e274f602 | Rust | SteadBytes/study | /general-exercises/leetcode/rust/src/longest_common_prefix.rs | UTF-8 | 3,152 | 3.640625 | 4 | [] | no_license | #![allow(dead_code)]
pub struct Solution {}
impl Solution {
pub fn longest_common_prefix(strs: Vec<String>) -> String {
match Self::lcp_index(&strs) {
Some(i) => String::from(&strs[0][..i]),
None => String::new(),
}
}
/// If a longest common prefix exists in `strs`... | true |
7c8e136d318195a2aa2349af250a05915e5ed22a | Rust | Lakret/cassandra-rs | /src/examples/collections.rs | UTF-8 | 2,019 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | #[macro_use(stmt)]
extern crate cassandra;
use cassandra::*;
use std::str::FromStr;
fn insert_into_collections(session: &mut Session, key: &str, items: Vec<&str>) -> Result<CassResult, CassError> {
let mut statement = stmt!("INSERT INTO examples.collections (key, items) VALUES (?, ?);");
try!(statement.bind(... | true |
3290cc9e7fc6a81c5d011384f4680518ddf43e30 | Rust | jonas-schievink/rubble | /rubble/src/link/filter.rs | UTF-8 | 3,484 | 3.53125 | 4 | [
"0BSD",
"BSD-3-Clause"
] | permissive | //! Link-Layer Device Filtering.
use super::DeviceAddress;
use core::{iter, slice};
pub trait AddressFilter {
fn matches(&self, address: DeviceAddress) -> bool;
}
/// An `AddressFilter` that allows all devices (ie. no whitelist in use).
pub struct AllowAll;
impl AddressFilter for AllowAll {
fn matches(&self... | true |
305e2efcead925128f0e2a93b3fe7379432db064 | Rust | ryutaroikeda/rustgammon | /tests/rustgammon-tests.rs | UTF-8 | 9,706 | 2.734375 | 3 | [] | no_license | extern crate rustgammon;
use rustgammon::rustgammon::*;
#[test]
fn test_is_all_home_true_for_empty() {
let game: Backgammon = Default::default();
assert!(game.is_all_home(Color::Red));
assert!(game.is_all_home(Color::White));
}
#[test]
fn test_is_all_home_false_for_non_home_checker() {
let mut game: B... | true |
e0ce765e1b751748566ce3cb3cc964f414012ccb | Rust | andypeng2015/SSVM | /bindings/rust/wasmedge-sys/examples/threads.rs | UTF-8 | 2,173 | 3.484375 | 3 | [
"Apache-2.0",
"CC0-1.0"
] | permissive | //! This example is to demonstrate computing multiple Fibonacci numbers concurrently.
//!
//! The main thread is responsible for computing `Fib(4), while a child thread is taking care of `Fib(5)`. Finally,
//! `Fib(6)` can be computed with the results of `Fib(5)` and `Fib(4)`.
use std::{
sync::{Arc, Mutex},
th... | true |
6e079a15600f3b04e335eb30d49bd43d1a1da0eb | Rust | quodlibetor/lasagna-demo | /50-traits/src/main.rs | UTF-8 | 584 | 2.90625 | 3 | [] | no_license | mod cache;
mod cache_metrics;
mod hash_cache;
use cache::Cache;
use cache_metrics::CacheMetrics;
use hash_cache::HashCache;
fn main() {
let mut cache = CacheMetrics::with(HashCache::new());
let key = 5;
do_something(&mut cache, key);
do_something(&mut cache, key);
do_something(&mut cache, key);
... | true |
33c1b21b8bdf84a486d7cb19b0396a4c5418253a | Rust | arturkow2000/rust-psutil | /src/utils.rs | UTF-8 | 468 | 2.828125 | 3 | [
"MIT"
] | permissive | use std::time::Duration;
use crate::Percent;
// TODO: switch this to nightly div_duration_f64
pub(crate) fn div_duration_f64(lhs: Duration, rhs: Duration) -> f64 {
lhs.as_secs_f64() / rhs.as_secs_f64()
}
pub(crate) fn duration_percent(lhs: Duration, rhs: Duration) -> Percent {
(div_duration_f64(lhs, rhs) * 100.0) ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.