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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
c7f268116f4b45fe2e555dd604d6c239ba43ad57 | Rust | jinlf/wukong | /src/lexer.rs | UTF-8 | 5,230 | 3.203125 | 3 | [] | no_license | use crate::token;
use core::fmt::Display;
pub struct Lexer {
pub input: String,
pub pos: usize,
pub read_pos: usize,
pub ch: u8,
}
pub fn new<S: AsRef<str>>(input: S) -> Lexer {
let mut l = Lexer {
input: String::from(input.as_ref()),
pos: 0,
read_pos: 0,
ch: 0,
... | true |
1e1cfdc313d3f2ff8a24886433ed65ab37e8061f | Rust | Ryanmtate/fluvio | /src/cli/src/topic/describe.rs | UTF-8 | 2,955 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | //!
//! # Describe Topic CLI
//!
//! CLI to describe Topics and their corresponding Partitions
//!
use structopt::StructOpt;
use flv_client::profile::ControllerTargetConfig;
use flv_client::profile::ControllerTargetInstance;
use crate::Terminal;
use crate::error::CliError;
use crate::OutputType;
use crate::tls::TlsC... | true |
416ca33b8fa0487b21e50db57bafc3fa38914d49 | Rust | thatsokay/advent-of-code | /2021/08/solution.rs | UTF-8 | 3,775 | 3.15625 | 3 | [] | no_license | use std::collections::{BTreeSet, HashMap};
use std::fs;
type Entry = (Vec<BTreeSet<char>>, Vec<BTreeSet<char>>);
fn main() {
let input = parse_input();
println!("{}", part1(&input));
println!("{}", part2(&input));
}
fn parse_input() -> Vec<Entry> {
fs::read_to_string("input.txt")
.unwrap()
... | true |
f0cdcaf4b06c4bb2cbf3d7c60162d7f4e4b46bb3 | Rust | oberzs/duku | /src/color/rgbf.rs | UTF-8 | 4,917 | 3.125 | 3 | [
"Apache-2.0"
] | permissive | // Oliver Berzs
// https://github.com/oberzs/duku
use super::mixf;
use super::Hsb;
use super::Mix;
use super::Rgb;
/// Color floats in RGB with alpha.
///
/// Makes it easier to handle/convert colors.
///
/// # Examples
///
/// ```
/// # use duku::Rgbf;
/// let red = Rgbf::red(0.7);
/// ```
#[derive(Debug, Copy, Clon... | true |
8db75252df5e22df91aa84658fa3c4b19fc8434c | Rust | jakubdabek/metaheuristic-algorithms | /list3/z3/src/point.rs | UTF-8 | 1,594 | 3.21875 | 3 | [] | no_license | use ndarray::prelude::*;
use ndarray::IntoDimension;
use std::fmt;
use std::ops::*;
#[derive(Debug, Clone, Copy, Ord, PartialOrd, Eq, PartialEq, Hash)]
pub struct Point {
pub x: u64,
pub y: u64,
}
impl Point {
#[inline]
pub fn new(x: u64, y: u64) -> Self {
Self { x, y }
}
}
impl fmt::Disp... | true |
d87e475542239a8179785d51b629fa69d4b7e946 | Rust | ecafkoob/ockam | /tools/ockam-hub-cli/src/auth/github.rs | UTF-8 | 3,413 | 2.890625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use colored::*;
use std::collections::HashMap;
use std::future::Future;
use std::pin::Pin;
use webbrowser;
const GITHUB_CLIENT_ID: &'static str = "609323e5ba23958cb2f5";
pub async fn post(
client: &reqwest::Client,
url: &str,
payload: &HashMap<&str, &str>,
) -> Result<HashMap<String, String>, reqwest::Err... | true |
9de1ffea96643af15840aa2f92c71d4bb878f33f | Rust | gitwithterrence/sybil | /frame/rewards/src/lib.rs | UTF-8 | 3,273 | 2.515625 | 3 | [
"Unlicense"
] | permissive | #![cfg_attr(not(feature = "std"), no_std)]
pub use pallet::*;
#[frame_support::pallet]
pub mod pallet {
use frame_support::{pallet_prelude::*, traits::Currency};
use frame_system::pallet_prelude::*;
use sp_runtime::DigestItem;
use sp_consensus_pow::POW_ENGINE_ID;
#[pallet::config]
pub trait Config: frame_syst... | true |
3317396b11a9e3929311e8dcc114941531c24dad | Rust | wthrowe/osstring_prototype | /src/windows/mod.rs | UTF-8 | 8,745 | 2.65625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | true |
764458540fbe24877b7a53af0606df73d5eee345 | Rust | valeth/wanikani.rs | /src/model/assignment.rs | UTF-8 | 2,022 | 2.90625 | 3 | [
"MIT"
] | permissive | use super::Time;
#[derive(Clone, PartialEq, Debug, Deserialize)]
pub struct Assignment {
pub created_at: Time,
pub subject_id: u32,
pub subject_type: String,
pub level: u8,
pub srs_stage: u8,
pub srs_stage_name: String,
pub unlocked_at: Option<Time>,
pub start... | true |
881eb470004b8e70ed4077cdb3e42f467ae5638a | Rust | webworker01/onetagger | /src/ui/quicktag.rs | UTF-8 | 3,225 | 2.859375 | 3 | [
"Apache-2.0"
] | permissive | use std::error::Error;
use std::collections::HashMap;
use std::fs::read_dir;
use std::io::Cursor;
use image::ImageOutputFormat;
use image::io::Reader as ImageReader;
use serde::{Deserialize, Serialize};
use crate::tag::{AudioFileFormat, Field, Tag};
pub struct QuickTag {}
impl QuickTag {
//Load all supported fil... | true |
dba7f0877a1afd3f43a6d90f6356db6eeb3de00d | Rust | Lite5h4dow/aleph.js | /compiler/src/strip_ssr.rs | UTF-8 | 2,804 | 2.625 | 3 | [
"MIT"
] | permissive | use crate::resolve_fold::is_call_expr_by_name;
use swc_common::DUMMY_SP;
use swc_ecma_ast::*;
use swc_ecma_visit::{noop_fold_type, Fold, FoldWith};
pub fn strip_ssr_fold(specifier: &str) -> impl Fold {
StripSSRFold {
specifier: specifier.into(),
}
}
pub struct StripSSRFold {
specifier: String,
}
impl Fold ... | true |
c2c475f5ee8e6e6dc4bc1ded38710447c9d9bb52 | Rust | technolapin/wave | /src/main.rs | UTF-8 | 4,405 | 3.046875 | 3 | [] | no_license | extern crate image;
use std::f32;
use f32::consts::PI;
use f32::consts::FRAC_PI_2;
const PROD_PI_2: f32 = 2.0*PI;
const BORNE_INF_DICHO: f32 = FRAC_PI_2;
const BORNE_SUP_DICHO: f32 = FRAC_PI_2+PROD_PI_2;
// this is the maximum error of height
// you can change this as you wish
// 0.01 looks far enought in this examp... | true |
e5235b5c6195b65210c36bbca0d92d62fab4dbab | Rust | HerringtonDarkholme/leetcode | /src/subdomain_visit.rs | UTF-8 | 695 | 2.71875 | 3 | [] | no_license | pub struct Solution;
use std::collections::HashMap;
impl Solution {
pub fn subdomain_visits(cpdomains: Vec<String>) -> Vec<String> {
let mut map = HashMap::new();
for s in cpdomains {
let sp: Vec<&str> = s.split(' ').collect();
let n: usize = sp[0].parse().unwrap();
... | true |
a36e33d1f174f431f14a23dde5b32ae6777b6a43 | Rust | natestedman/aoc | /src/q3.rs | UTF-8 | 5,381 | 3.078125 | 3 | [] | no_license | use itertools::iproduct;
use nom::branch::alt;
use nom::bytes::complete::tag;
use nom::character::complete::{digit1, newline};
use nom::combinator::{map, map_res};
use nom::multi::separated_list;
use nom::sequence::{pair, separated_pair};
use std::cmp::min;
use std::io::{stdin, Read};
use std::str::FromStr;
use structo... | true |
2fb796d916a0c3cbe034e858ac902c6ea571014a | Rust | clemensw/async-std | /src/io/timeout.rs | UTF-8 | 1,645 | 3 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::pin::Pin;
use std::time::Duration;
use futures_timer::Delay;
use pin_utils::unsafe_pinned;
use crate::future::Future;
use crate::io;
use crate::task::{Context, Poll};
/// Awaits an I/O future or times out after a duration of time.
///
/// # Examples
///
/// ```no_run
/// # fn main() -> std::io::Result<()> {... | true |
2cc0f797799f4da3790344e106665c7171fa8f50 | Rust | melekes/tendermint-rs | /proto/src/serializers/evidence.rs | UTF-8 | 1,877 | 2.953125 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"Apache-2.0"
] | permissive | use crate::tendermint::types::evidence::Sum;
use crate::tendermint::types::Evidence;
/// EvidenceVariant helper struct for evidence serialization
/// This is a workaround until we figure a better way of JSON serializing evidence.
/// It is a modified copy of the crate::tendermint::types::evidence::Sum struct.
#[allow(... | true |
4c65a82194203a604c1254f1d81f6a18b8c20e70 | Rust | Dokuro-YH/hamster-rs | /src/db/groups/types.rs | UTF-8 | 1,832 | 2.625 | 3 | [
"MIT"
] | permissive | use std::io;
use chrono::prelude::*;
use diesel::deserialize::{self, FromSql};
use diesel::pg::Pg;
use diesel::serialize::{self, IsNull, Output, ToSql};
use diesel::sql_types::Text;
use uuid::Uuid;
use crate::schema::groups;
#[derive(Debug, PartialEq, Deserialize, Serialize, Insertable, Queryable)]
#[table_name = "g... | true |
fe56dcdc5563a3992441b424cea3343aa962b36f | Rust | jumbojets/greedy-shopper | /src/itenerary.rs | UTF-8 | 579 | 2.96875 | 3 | [
"MIT",
"Python-2.0",
"Apache-2.0"
] | permissive | use pyo3::prelude::*;
use std::collections::HashSet;
use super::store::*;
#[pyclass]
#[derive(Clone)]
pub struct Itenerary {
#[pyo3(get)]
pub stores: HashSet<Store>,
pub items_covered: HashSet<String>,
}
impl Itenerary {
pub fn new() -> Self {
let stores: HashSet<Store> = HashSet::new();
let items_covered: Ha... | true |
7ea1376c982c0d5ba87937d3f8c516cb553f1784 | Rust | unknownue/leetcode.rs | /tests/p00xx/t35.rs | UTF-8 | 1,458 | 2.96875 | 3 | [
"MIT"
] | permissive |
use leetcode_rs::p00xx::p35::*;
#[derive(Debug, Clone)]
struct TestCase {
input : Input,
answer: Output,
}
#[test]
fn t35() {
let solutions = [
Box::new(Solution0) as Box<dyn Solution>,
Box::new(Solution1) as Box<dyn Solution>,
];
let test_cases = [
TestCase {
... | true |
ade2b3464a35d26956abac5d9ca3777b7ffbc565 | Rust | Nashenas88/moxie | /dom/examples/todo/src/header.rs | UTF-8 | 981 | 2.796875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use {
crate::{input::TextInput, Todo},
moxie_dom::prelude::*,
tracing::info,
};
#[derive(Clone, Debug, PartialEq)]
pub struct Header {
todos: Key<Vec<Todo>>,
}
impl Header {
pub fn new(todos: Key<Vec<Todo>>) -> Self {
Self { todos }
}
}
impl Component for Header {
fn contents(self... | true |
a514552f321af45aee0e91758b1ce270a1012564 | Rust | Kayryu/rust-statemachine | /src/fsm.rs | UTF-8 | 841 | 3.625 | 4 | [
"MIT"
] | permissive | use crate::error::FsmError;
use crate::event::Event;
#[derive(Default)]
pub struct State {
pub name: String,
pub enter: Option<fn()>,
pub leave: Option<fn()>,
}
/*
usage:
let mut fsm = FSM::new();
fsm.event("v1").from(state::1).to(state::2).action(|| {
});
fsm.run();
older:
let state = v1;
if state ... | true |
309acef08d98159694a2c37b51787afbc0a299fb | Rust | driedtoast/rusties | /src/commands/screenplay.rs | UTF-8 | 3,282 | 3.125 | 3 | [] | no_license | use seahorse::{Context, Command};
use fountain;
use fountain::data::{Document, Line};
use nom::error::{ErrorKind, VerboseError};
use std::fs::File;
use std::io;
use std::io::prelude::*;
use std::collections::HashSet;
fn screenplay_action(c: &Context) {
if c.args.is_empty() {
println!("screen file not found... | true |
76e9fcad4f67f0557724bfa4a7a04994cb6911be | Rust | iptq/rosu-v2 | /src/routing.rs | UTF-8 | 5,712 | 2.59375 | 3 | [
"MIT"
] | permissive | use crate::{
model::{ranking::RankingType, GameMode},
request::{ScoreType, UserId},
};
use hyper::Method;
use std::{borrow::Cow, fmt::Write};
#[allow(clippy::enum_variant_names)]
#[derive(Debug)]
#[non_exhaustive]
pub(crate) enum Route {
GetBeatmap,
GetBeatmapScores {
map_id: u32,
},
G... | true |
dd61251f97d1e18b6f376e54a89f331be0756959 | Rust | DGeisz/eywa | /src/neuron/synapse.rs | UTF-8 | 7,315 | 3.453125 | 3 | [] | no_license | use std::boxed::Box;
use std::cell::RefCell;
use std::rc::Rc;
use synaptic_strength::SynapticStrength;
use crate::neuron::NeuronicRx;
/// All synapses have the capability to fire
pub trait Synapse {
/// Fires the synapse. Pretty basic
fn fire(&self);
}
/// A synapse can strengthen and weaken in different
///... | true |
e8369aea1ebf257d9c6e460335255c353bf5ce0e | Rust | luizdepra/exercism | /rust/minesweeper/src/lib.rs | UTF-8 | 1,043 | 3 | 3 | [] | no_license | use std::char;
use itertools::iproduct;
pub fn annotate(minefield: &[&str]) -> Vec<String> {
minefield.iter().enumerate().map(|(y, row)| {
row.char_indices().map(|(x, cell)| {
match cell {
' ' => {
let count = count_neighbor_mines(minefield, x, y) as u32;
... | true |
8428ed65f0d63e59cae67abb8d6c41e811cbed47 | Rust | krishnakumar4a4/casync-dashboard-backend | /src/json.rs | UTF-8 | 4,064 | 3.171875 | 3 | [
"MIT"
] | permissive | use std::fs::File;
use std::path::Path;
use std::io::Read;
use std::io::Write;
extern crate serde;
//#[macro_use]
extern crate serde_json;
#[macro_use]
extern crate serde_derive;
#[derive(Serialize, Deserialize)]
pub struct Chunk {
name: String,
size: String
}
#[derive(Serialize, Deserialize)]
pub struct Ind... | true |
2f37b431aa8962c06bc3e868be136fe3ac2124a5 | Rust | bpa/advent-of-code | /2020/src/day4.rs | UTF-8 | 5,123 | 2.90625 | 3 | [] | no_license | use regex::Regex;
use std::collections::HashSet;
#[aoc(day4, part1)]
pub fn valid_passports(input: &str) -> usize {
let required: HashSet<String> = ["byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid"]
.iter()
.map(|&f| String::from(f))
.collect();
let mut existing = HashSet::with_capacity(... | true |
9012df75ee4c5e03e46254040ba250f5e58dfb4a | Rust | Ventmere/walmart-partner-api | /cli/src/item.rs | UTF-8 | 780 | 2.546875 | 3 | [
"MIT"
] | permissive | use serde_json;
use walmart_partner_api::item::*;
use walmart_partner_api::Client;
pub fn dump(client: &Client) {
let mut params: GetAllItemsQueryParams = Default::default();
params.limit = Some(20);
let mut items = vec![];
loop {
println!("loading params = {:#?}, total = {}", params, items.len());
le... | true |
edfdafff4b8d724713133b956bee1a563ea41f18 | Rust | Juici/int-enum-rs | /src/lib.rs | UTF-8 | 3,409 | 3.65625 | 4 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! A procedural macro for conversion between integer and enum types.
#![allow(clippy::module_name_repetitions)]
#![cfg_attr(not(feature = "std"), no_std)]
mod error;
mod int;
use core::marker::{Copy, Sized};
use core::result::Result;
use self::int::PrimInt;
/// Trait used for implementations of integer and enum c... | true |
3bfa4b0338e083cce060adf1714279359a6501af | Rust | michalkadlubowski/Learning-Rust | /src/website_handler.rs | UTF-8 | 2,601 | 3.15625 | 3 | [] | no_license |
use crate::http::QueryString;
use crate::http::QueryStringValue as QueryStringValue;
use super::{http::{Response, StatusCode, Method}, server::Handler};
use std::{fs};
pub struct WebsiteHandler {
public_path: String
}
impl WebsiteHandler {
pub fn new(public_path: String) -> Self{
WebsiteHandler { pu... | true |
8c99ca19d9f8c70ec76bd6cf66987d847db05105 | Rust | tubo28/six-nimmt | /src/ai/monte_carlo_ai.rs | UTF-8 | 608 | 2.71875 | 3 | [] | no_license | use crate::ai::ai::AI;
use crate::ui::game::Card;
use crate::ui::game::ViewOnChoosingCard;
use crate::ui::game::ViewOnGatheringRow;
#[derive(Clone)]
pub struct MonteCalroAI {
name: String,
}
impl MonteCalroAI {
pub fn new(name: String) -> MonteCalroAI {
MonteCalroAI { name: name }
}
}
impl AI for... | true |
b23402699e8316d1346fe095a01f0a6497bcddcd | Rust | embedded-graphics/embedded-graphics | /src/primitives/triangle/scanline_intersections.rs | UTF-8 | 7,213 | 3.109375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | //! Triangle scanline intersections iterator.
use crate::{
geometry::Point,
primitives::{
common::{LineJoin, PointType, Scanline, StrokeOffset, ThickSegment},
Triangle,
},
};
#[derive(Clone, Eq, PartialEq, Hash, Debug)]
#[cfg_attr(feature = "defmt", derive(::defmt::Format))]
struct LineCon... | true |
00fa357238799b357652f093b72f0c016ad20da4 | Rust | katandps/beatoraja_play_recommend | /crates/model/src/score/updated_at.rs | UTF-8 | 2,737 | 3.203125 | 3 | [
"MIT"
] | permissive | use crate::*;
use anyhow::Result;
use chrono::{DateTime, Duration, NaiveDateTime, ParseError, TimeZone, Utc};
use std::fmt;
use std::ops::Sub;
use std::str::FromStr;
#[derive(Clone, Ord, PartialOrd, Eq, PartialEq, Debug, Serialize, Deserialize, Hash)]
pub struct UpdatedAt(DateTime<Utc>);
impl Default for UpdatedAt {
... | true |
4676aa69a38590b51d409dcf0b90abd006e33d87 | Rust | itto-ki/atcoder | /ABC/002/D.rs | UTF-8 | 1,376 | 3.125 | 3 | [] | no_license | const N_MAX: usize = 12;
fn i32_to_bitvec(integer: i32) -> Vec<bool> {
let mut v: Vec<bool> = Vec::new();
for i in 0..N_MAX {
if integer & (1 << i) > 0 {
v.push(true);
} else {
v.push(false);
}
}
v
}
#[allow(unused_must_use)]
fn read_usize_pair() -> (usi... | true |
e291ddc5f5853bc48d2bd4e85fd42dc59b565c46 | Rust | davenport-rust/functional-snake | /src/gamewindowsettings.rs | UTF-8 | 1,222 | 2.546875 | 3 | [
"MIT"
] | permissive | extern crate piston_window;
extern crate sdl2_window;
extern crate find_folder;
use piston_window::*;
use sdl2_window::*;
use std::path::PathBuf;
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd)]
pub struct GameWindowSettings {
pub window_height: u32,
pub window_width: u32,
pub block_size: u32... | true |
718cf534b3cc6ad02bb8b62dedf5f9c5bf6b2744 | Rust | marco-c/gecko-dev-comments-removed | /third_party/rust/regex-syntax/src/either.rs | UTF-8 | 109 | 2.765625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive |
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum Either<Left, Right> {
Left(Left),
Right(Right),
}
| true |
497c0c059189290934a8fc3f76a04d52de129cd0 | Rust | marco-c/gecko-dev-wordified | /third_party/rust/darling/examples/consume_fields.rs | UTF-8 | 4,740 | 2.578125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | /
/
The
use
of
fields
in
debug
print
commands
does
not
count
as
"
used
"
/
/
which
causes
the
fields
to
trigger
an
unwanted
dead
code
warning
.
#
!
[
allow
(
dead_code
)
]
/
/
!
This
example
shows
how
to
do
struct
and
field
parsing
using
darling
.
use
darling
:
:
{
ast
FromDeriveInput
FromField
FromMeta
}
;
use
proc_ma... | true |
72dabe3577193f27efb17cfbe6f23563b824617d | Rust | likr/atcoder | /abc169/src/bin/b.rs | UTF-8 | 854 | 2.65625 | 3 | [] | no_license | use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;
#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;
#[... | true |
09b6647c3140be6cd0395d719a408eb7f55ba33e | Rust | playXE/librcimmixcons | /src/gc_object.rs | UTF-8 | 8,700 | 2.53125 | 3 | [
"MIT"
] | permissive | // Copyright (c) <2015> <lummax>
// Licensed under MIT (http://opensource.org/licenses/MIT)
extern crate libc;
use std::mem;
use std::ops::Range;
use constants::LINE_SIZE;
/// Structs that comprise the structure of an object as needed by the garbage
/// collector.
///
/// Include the `GCObject` struct as the first ... | true |
4b5a23d0b6a1c17e9d5375688811077e99bc2a1b | Rust | holzingk/advent-of-code-2020 | /src/bin/day10.rs | UTF-8 | 3,508 | 3.234375 | 3 | [] | no_license | use std::fs::File;
use std::io::{BufReader, BufRead};
use itertools::Itertools;
fn main() {
println!("Count 1 {}", day10_1());
println!("Count 2 {}", day10_2());
}
fn day10_1() -> u64 {
let mut adapters = parse("data/10");
task1(&mut adapters)
}
fn day10_2() -> u64 {
let mut adapters = parse("dat... | true |
cef31b17b73047b5a9936a35a8dbd7d7818e6282 | Rust | cleverhero/PasC | /src/ParserPack/Nodes/main_node.rs | UTF-8 | 1,417 | 2.75 | 3 | [] | no_license | use GeneratorPack::*;
use std::fmt;
use std::fmt::Display;
use std::rc::Rc;
use ParserPack::Nodes::support::*;
#[derive(Clone)]
pub struct MainNode {
pub name: String,
pub childrens: Vec<Rc<Node>>,
}
impl MainNode {
pub fn new(name: String) -> MainNode {
MainNode {
name: name,
... | true |
137d6e274f70cafebc913bb3cf7085693c085c78 | Rust | EFanZh/LeetCode | /src/problem_1340_jump_game_v/dfs.rs | UTF-8 | 1,758 | 2.96875 | 3 | [] | no_license | pub struct Solution;
// ------------------------------------------------------ snip ------------------------------------------------------ //
impl Solution {
fn dfs(arr: &[i32], d: usize, node: usize, cache: &mut [u32]) -> u32 {
let candidate = cache[node];
if candidate == 0 {
let hei... | true |
f18956e2daf45c5b175937db2e31e1d0e9d76f78 | Rust | RSSchermer/ARWA | /arwa/src/cssom/animation/animation_event.rs | UTF-8 | 2,136 | 2.953125 | 3 | [
"MIT"
] | permissive | use delegate::delegate;
mod animation_event_seal {
pub trait Seal {}
}
/// Implemented for animation-related event types.
pub trait AnimationEvent: animation_event_seal::Seal {
/// Returns the [CSS animation-name](https://developer.mozilla.org/en-US/docs/Web/CSS/animation-name)
/// of the CSS animation th... | true |
7dbedca8330051d39a004d6937bf8f9efa541aa5 | Rust | simonfuture2/helium-api-rs | /src/hotspots.rs | UTF-8 | 2,937 | 2.828125 | 3 | [
"Apache-2.0"
] | permissive | use crate::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Serialize, Deserialize, Debug)]
pub struct Geocode {
/// The long version of city for the last asserted location
pub long_city: Option<String>,
/// The long version of country for the last asserted location
pub long_country: Option<Stri... | true |
37927b5bef42d278331d99f6a0e99adfb68daf0a | Rust | Norris1z/file-merger | /src/main.rs | UTF-8 | 1,697 | 3.015625 | 3 | [] | no_license | mod config;
use std::env;
use std::error;
use std::fs::File;
use std::io::prelude::*;
use std::io::{self, BufRead, Error, LineWriter};
use std::path::Path;
use std::sync::mpsc::channel;
use threadpool::ThreadPool;
fn executable_path() -> Result<String, Error> {
let mut dir = env::current_exe()?;
dir.pop();
... | true |
3dfe75f0a433dd975ae9aeb9abee0225e4e4da1d | Rust | TrueDoctor/DiscoBot | /webhogg/game_engine/src/math/vec3.rs | UTF-8 | 4,284 | 3.53125 | 4 | [] | no_license | use std::cmp::Ordering;
use std::ops;
use crate::math::EPSILON;
/// A 3-dimensional euclidean vector.
#[derive(Clone, Copy, Debug)]
pub struct Vec3 {
/// The x coordinate.
x: f32,
/// The y coordinate.
y: f32,
/// The z coordinate.
z: f32,
}
impl ops::Add for Vec3 {
type Output = Self;
... | true |
80cde8970f94a673849efaa3d471983e1883a7ea | Rust | wayofthepie/bst-trim-post | /src/rc_tree.rs | UTF-8 | 4,107 | 3.734375 | 4 | [] | no_license | use std::{cell::RefCell, rc::Rc};
#[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,
left: ... | true |
ad8537e68b87184f3dd9f4708a811d60beb1a873 | Rust | pzol/r18n | /src/lib.rs | UTF-8 | 3,265 | 2.6875 | 3 | [] | no_license | #![feature(custom_derive, path, io, collections, core, libc)]
extern crate collections;
extern crate toml;
extern crate libc;
mod error;
use error::Error;
use std::fs::File;
use std::ffi::CString;
use libc::{c_char, c_int, size_t};
use std::borrow::ToOwned;
use std::path::AsPath;
use std::io::{ self, Read };
use std... | true |
47f09d2da66d7b5dcbdbffca02beb70ae46337b8 | Rust | evanxg852000/faker-rs | /faker/src/random.rs | UTF-8 | 5,207 | 3.0625 | 3 | [
"MIT"
] | permissive | use std::rc::Rc;
use std::cell::RefCell;
use crate::engine::{ Engine, FakerValue };
use crate::traits::Generator;
use rand::{ Rng, rngs::ThreadRng };
use rand::distributions::{ uniform::SampleUniform };
use uuid::Uuid;
const ALPHA_CHARSET: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
const NUMERI... | true |
51a89053f1a1d8b3412e7fc45d4e6f3be95e515b | Rust | HeadBeeGuy/Advent-of-Code-2019 | /day02/rust/day02pt2/src/main.rs | UTF-8 | 1,912 | 3.296875 | 3 | [] | no_license | // This is probably not good Rust at all - reading vectors with no error handling!
// There must be a more elegant way to do it! But it finds the solution very
// quickly nonetheless.
use std::fs;
fn main() {
let base_opcodes = fs::read_to_string("../../input.txt").expect("You got the file path wrong!");
let b... | true |
3338fa42e64c86de26736df9dc41af25def01a3c | Rust | evaporei/design-patterns | /behavioral/command/rust/src/lib.rs | UTF-8 | 1,286 | 3.8125 | 4 | [] | no_license | pub trait Order {
fn execute(&self);
}
pub struct Stock {
name: String,
quantity: isize,
}
impl Stock {
pub fn new() -> Self {
Stock { name: "ABC".to_string(), quantity: 10 }
}
fn buy(&self) {
println!("Stock [ Name: {}, Quantity: {} ] bought", self.name, self.quantity);
}
... | true |
0019988e0799158a2106d96803b02269da4e3718 | Rust | mikeduminy/entelect-challenge-tower-defence | /src/engine/command.rs | UTF-8 | 1,588 | 3.375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use std::fmt;
use super::constants::*;
use super::geometry::Point;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Command {
Nothing,
Build(Point, BuildingType),
IronCurtain
}
impl fmt::Display for Command {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
... | true |
742013c015cabf710598e7413c62ff44d3816783 | Rust | duanshaoyang/LibIsolationForest | /rust/src/main.rs | UTF-8 | 3,839 | 2.625 | 3 | [
"MIT"
] | permissive | // MIT License
//
// Copyright © 2018 Michael J Simms. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights... | true |
2a1b19e29f304de66a3ba240e6ab1dbc07865003 | Rust | DevinR528/matrix-canonical-json-rs | /src/map_key.rs | UTF-8 | 5,311 | 2.84375 | 3 | [] | no_license | use std::{fmt, io};
use serde::{
ser::{self, Error as _, Impossible},
serde_if_integer128, Serialize,
};
use crate::{serializer::Serializer, Error, Result};
pub struct MapKeySerializer<'a, W: 'a> {
pub ser: &'a mut Serializer<W>,
}
#[cfg(feature = "arbitrary_precision")]
fn invalid_number() -> Error {
... | true |
eda2f502a947d2a57e1088bdd4fdc470322c9c21 | Rust | typst/typst | /crates/typst-library/src/math/fragment.rs | UTF-8 | 15,230 | 2.65625 | 3 | [
"Apache-2.0",
"Bitstream-Vera",
"CC-BY-4.0",
"OFL-1.1",
"LicenseRef-scancode-gust-font-1.0",
"BSD-3-Clause",
"LicenseRef-scancode-ubuntu-font-1.0",
"0BSD",
"LicenseRef-scancode-free-unknown",
"LicenseRef-scancode-public-domain",
"MIT",
"LicenseRef-scancode-public-domain-disclaimer"
] | permissive | use rustybuzz::Feature;
use ttf_parser::gsub::{
AlternateSet, AlternateSubstitution, SingleSubstitution, SubstitutionSubtable,
};
use ttf_parser::opentype_layout::LayoutTable;
use super::*;
#[derive(Debug, Clone)]
pub enum MathFragment {
Glyph(GlyphFragment),
Variant(VariantFragment),
Frame(FrameFragm... | true |
96f1e1d8b7786965994130fba4be5686b0f305c6 | Rust | quentpilot/my-rust-tests | /sql-generator/src/arguments.rs | UTF-8 | 943 | 3.171875 | 3 | [
"MIT"
] | permissive | use std::env;
pub struct Argument {
pub name: String,
pub value: String,
}
pub struct Wanted {
name: String
}
impl Wanted {
fn new(name: String) -> Wanted {
Wanted {
name: name.to_string()
}
}
}
impl Argument {
fn new(name: String, value: String) -> Argument {
... | true |
2d66328f36274adfcc0f0b127ffda85810716459 | Rust | abingham/roid-rage-rust | /roid-rage/src/systems/move_objects.rs | UTF-8 | 1,035 | 2.6875 | 3 | [] | no_license | use crate::components::{AngularVelocity, LinearVelocity, Position, Rotation, TimeDelta};
use specs::{Join, Read, ReadStorage, System, WriteStorage};
pub struct MoveObjectsSystem;
impl<'s> System<'s> for MoveObjectsSystem {
type SystemData = (
WriteStorage<'s, Position>,
WriteStorage<'s, Rotation>,... | true |
a14790a9374807ab82ab953982e3fc9204fca28d | Rust | carbidegames/soto | /sotolib-fbx/src/simple/mod.rs | UTF-8 | 6,920 | 3.109375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | mod animation;
mod geometry;
mod model;
mod object;
mod properties;
pub use self::animation::{AnimationCurve};
pub use self::geometry::{Geometry};
pub use self::model::{Model, ModelProperties};
pub use self::object::{Object, ObjectType};
pub use self::properties::{Property, Properties};
use std::collections::{HashMap... | true |
9150d6aa789121a26f273c8032c9ce80bac7c796 | Rust | jonathansharman/adventure | /src/component/tile_coords.rs | UTF-8 | 653 | 3.015625 | 3 | [
"MIT"
] | permissive | use crate::constants::TILE_SIZE;
use bevy::math::Vec2;
use serde::Deserialize;
#[derive(Clone, Copy, PartialEq, Eq, Deserialize)]
pub struct TileCoords {
pub row: usize,
pub col: usize,
}
impl From<TileCoords> for Vec2 {
fn from(tile_coords: TileCoords) -> Self {
Vec2::new(
tile_coords.col as f32 * TILE_SIZE... | true |
a3d8a2a901f4870cf1bd2be929af0b5a7261209c | Rust | blackblood/kv-lake | /src/stores/lfu/frequency_node.rs | UTF-8 | 542 | 3 | 3 | [
"MIT"
] | permissive | use std::sync::{ Arc, RwLock };
use super::list::List;
pub struct FrequencyNode<T: std::fmt::Display + std::clone::Clone> {
pub frequency: u32,
pub list: List<T>,
pub next: Option<Arc<RwLock<FrequencyNode<T>>>>,
pub prev: Option<Arc<RwLock<FrequencyNode<T>>>>
}
impl<T: std::fmt::Display + std::clone::... | true |
1587f33b97d8ea5cbc5d998416a6a28b0810c433 | Rust | AndWass/workops | /src/routes/api/mod.rs | UTF-8 | 1,191 | 2.671875 | 3 | [] | no_license | use crate::db::users::User;
use rocket::response::Debug;
use rocket::serde::json::Json;
use rocket::serde::{Serialize};
type DbContext = rocket::State<crate::db::DbContext>;
type ApiResult<T> = Result<Json<T>, Debug<sqlx::Error>>;
#[derive(Serialize)]
struct AllUsers {
users: Vec<User>,
}
#[rocket::get("/<id>")]... | true |
7166be78ba0df92d53bce490a94b12d17f850ec5 | Rust | psnszsn/degit-rs | /src/lib.rs | UTF-8 | 7,151 | 2.9375 | 3 | [] | no_license | use colored::*;
use flate2::read::GzDecoder;
use indicatif::{ProgressBar, ProgressStyle};
use regex::Regex;
use std::{error::Error, fmt, path::PathBuf};
use tar::Archive;
#[derive(Debug, PartialEq)]
enum Host {
Github,
Gitlab(String),
BitBucket,
}
#[derive(Debug, PartialEq)]
struct Repo {
host: Host,
... | true |
faea343af289a791529ef1c03ab60f77542eafb1 | Rust | Baelyk/advent-of-code | /src/day4.rs | UTF-8 | 9,574 | 3.390625 | 3 | [] | no_license | // Day 4 2019
#[cfg(test)]
mod tests {
use crate::day4::*;
#[test]
fn test_factorial() {
assert_eq!(factorial(0), 1);
assert_eq!(factorial(1), 1);
assert_eq!(factorial(2), 2);
assert_eq!(factorial(3), 6);
assert_eq!(factorial(10), 3628800);
}
#[test]
fn t... | true |
8c4f37621b74bfa245c4705c355b6e5452248a20 | Rust | mass10/rust.note | /code/enumerating-processes/src/main.rs | UTF-8 | 284 | 2.578125 | 3 | [] | no_license | fn enumerate_processes() {
use sysinfo::SystemExt;
let sys = sysinfo::System::new_all();
for (pid, process) in sys.get_processes() {
println!("[TRACE] {} {:?}", pid, process);
}
}
/// アプリケーションのエントリーポイント
fn main() {
enumerate_processes();
}
| true |
59f073acdb48de3dbf9be400b8810f1bd802d188 | Rust | gnoliyil/fuchsia | /src/lib/ui/keymaps/src/config.rs | UTF-8 | 2,673 | 2.828125 | 3 | [
"BSD-2-Clause"
] | permissive | // Copyright 2021 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//! Keymap configuration store.
//!
//! Used to load and store keymap configurations from configuration files.
use fidl_fuchsia_input as input;
use fidl_f... | true |
783c3ae22ecd38cf09bf520591622277efb373fb | Rust | rnleach/sounding-analysis | /src/layers/inversions.rs | UTF-8 | 4,725 | 2.984375 | 3 | [
"MIT"
] | permissive | use super::{Layer, Layers};
use crate::{
error::{AnalysisError, Result},
sounding::Sounding,
};
use itertools::{izip, Itertools};
use metfor::HectoPascal;
/// Get all inversion layers up to a specified pressure.
pub fn inversions(snd: &Sounding, top_p: HectoPascal) -> Result<Layers> {
let t_profile = snd.t... | true |
088cf7a4957b05c9868f179c07e4bc7dc1490412 | Rust | nuxeh/aoc-2020 | /03/src/main.rs | UTF-8 | 1,230 | 3.125 | 3 | [
"ISC"
] | permissive | use aocf::Aoc;
fn count_trees(i: &str, right: usize, down: usize) -> usize {
let mut trees = 0;
let v: Vec<Vec<bool>> = i
.lines()
.map(|l| {
l.repeat(200).chars().map(|c| c == '#').collect()
})
.collect();
v.chunks_exact(down)
.enumerate()
.for... | true |
079d20607f6cf3961eb94ce3bcf8b7cad8bb3ad3 | Rust | sbansal3096/gsoc2018-challenge | /middle/src/lib.rs | UTF-8 | 962 | 2.96875 | 3 | [] | no_license | extern crate base;
use base::{Logger, LogEntry};
use std::mem;
pub struct Middleware {
logger: Logger,
violations: Vec<LogEntry>,
}
impl Middleware {
fn new(logger: Logger) -> Middleware {
Middleware {
logger,
violations: vec![]
}
}
pub fn log_violation(&m... | true |
6f55ef23988535eb68bb3b38d85a533995002973 | Rust | DanielleB-R/advent-of-code | /2019/day3/src/main.rs | UTF-8 | 2,714 | 3.546875 | 4 | [
"MIT"
] | permissive | use std::io::{stdin, BufRead, Result};
type Point = (i32, i32);
fn intersects(pt: Point, coord: i32) -> bool {
coord >= pt.0 && coord <= pt.1
}
fn taxicab(pt: Point) -> i32 {
let dist = pt.0.abs() + pt.1.abs();
if dist == 0 {
i32::max_value()
} else {
dist
}
}
#[derive(Clone, Cop... | true |
fe7481169a600958e3a01b618c0707b34eab32df | Rust | 19h/rustun | /src/message/mod.rs | UTF-8 | 11,326 | 3.296875 | 3 | [
"MIT"
] | permissive | //! STUN message related components.
//!
//! > STUN is a client-server protocol. It supports two types of
//! > transactions. One is a **request/response** transaction in which a
//! > client sends a **request** to a server, and the server returns a
//! > **response**. The second is an **indication** transaction in wh... | true |
b64bd77f03330775397aa7fb2b9dfad2f62915a6 | Rust | vrruiz/asicamera2-example | /src/main.rs | UTF-8 | 9,683 | 2.546875 | 3 | [
"MIT"
] | permissive | extern crate asicamera2;
mod fitswriter;
use std::ffi::CStr;
use std::path::PathBuf;
fn main() {
println!("Using ZWO ASI C Library via Rust");
let image_bytes;
let image_size: usize;
// Read the number of connected cameras
let asi_connected_cameras = unsafe { asicamera2::ASIGetNumOfConnectedCam... | true |
ef4ab4a7cc9ea41b6e321d08a72407dd6c2622ba | Rust | wedaly/devlog | /src/path.rs | UTF-8 | 5,799 | 3.828125 | 4 | [
"MIT"
] | permissive | //! Path to a devlog entry file.
use crate::error::Error;
use std::cmp::Ordering;
use std::path::{Path, PathBuf};
/// The maximum possible sequence number of a devlog entry file.
pub const MAX_SEQ_NUM: usize = 999_999_999;
/// The number of digits in a devlog entry filename.
pub const NUM_DIGITS: usize = 9;
#[deriv... | true |
89fa3c5f18bc98b5e45710be4582089a24a4ef53 | Rust | nntto/fibonacci_heap | /src/lib.rs | UTF-8 | 13,548 | 2.921875 | 3 | [] | no_license | use std::cell::{Ref, RefCell};
use std::rc::{Rc, Weak};
pub struct Heap<T> {
n: isize,
min: Option<Rc<Node<T>>>,
}
pub struct InputData<T> {
key: isize,
value: T,
is_marked: bool,
children: Vec<InputData<T>>,
}
impl<T> Heap<T> {
// TODO
pub fn set_n(&mut self, n: isize) {
self... | true |
a95d186e67d47e903eca3d6fc9e38d08b9c4d97b | Rust | giodamelio/little_boxes | /vendor/indexmap/src/set/iter.rs | UTF-8 | 12,423 | 2.78125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use super::{Bucket, Entries, IndexSet, Slice};
use alloc::vec::{self, Vec};
use core::fmt;
use core::hash::{BuildHasher, Hash};
use core::iter::{Chain, FusedIterator};
use core::slice::Iter as SliceIter;
impl<'a, T, S> IntoIterator for &'a IndexSet<T, S> {
type Item = &'a T;
type IntoIter = Iter<'a, T>;
... | true |
0162df19f9cfa053e1c38d0210e334b1f11fd627 | Rust | TheKevJames/juicyj | /src/analysis/types/resolve/primitive.rs | UTF-8 | 4,314 | 2.65625 | 3 | [] | no_license | use analysis::environment::ClassOrInterface;
use analysis::environment::ClassOrInterfaceEnvironment;
use analysis::types::obj::Type;
use scanner::ASTNode;
use scanner::Token;
use scanner::TokenKind;
lazy_static! {
static ref BOOLEAN: Type = {
let node = ASTNode { token: Token::new(TokenKind::Boolean, None)... | true |
f424e31bf341e0d1bd3881b4eb2be7a2c516efd1 | Rust | DirtGrubDylan/adventofcode2019 | /src/day_14/mod.rs | UTF-8 | 1,495 | 3.21875 | 3 | [] | no_license | mod nanofactory;
use crate::file_reader::to_string_vector;
use nanofactory::Nanofactory;
pub fn run_day_14() {
let file_input = to_string_vector("inputs/day_14.txt");
match file_input {
Ok(reactions) => {
let mut nanofactory = Nanofactory::new();
for reaction in reactions {
... | true |
1d809de5bd05ba197c0271da0a0ec844f6c6fe28 | Rust | InterestingBrainPoops/battlesnake-rs | /battlesnake-rs/src/devious_devin_mutable.rs | UTF-8 | 16,163 | 2.515625 | 3 | [] | no_license | use crate::a_prime::APrimeCalculable;
use crate::*;
use battlesnake_game_types::types::*;
use std::sync::mpsc;
use std::thread;
use std::time::{Duration, Instant};
use tracing::{info, info_span};
pub struct DeviousDevin<T> {
game: T,
}
#[derive(Debug)]
pub struct Instruments;
impl SimulatorInstruments for Instr... | true |
15063fbb43f969b69962813c8833aabfce88bb0b | Rust | werner/focusvent | /src/handlers/sales.rs | UTF-8 | 2,337 | 2.671875 | 3 | [] | no_license | use crate::handlers::base::GetTransactionParams;
use rocket::response::status;
use rocket::http::Status;
use rocket_contrib::Json;
use crate::models::sale::Sale;
use crate::models::sale::FullSale;
use crate::models::sale::FullNewSale;
use crate::models::sale::SearchSale;
use crate::models::sale_status::SaleStatus;
#[g... | true |
cd37059e2d37b1de1966da0dad367ca07064ae4d | Rust | Ryan-Florida/NumericalAnalysisFun | /src/example3.rs | UTF-8 | 854 | 2.734375 | 3 | [] | no_license | //EXPECT THIS FILE TO GIVE NUMERICALLY UNSTABLE RESULTS.
//ROWS -> rows in grid.
pub const ROWS: usize = 101;
//COLS -> columns in grid.
pub const COLS: usize = 11;
//H -> Length (in meters) of linear segments.
pub const H: f64 = 1e-1;
//K -> Time step (in seconds) after calculations start.
pub const K: f64 = 1e-2;
/... | true |
bf17bbf9daadf03c397a4c9aafbd3a882bd60cf9 | Rust | marmeladema/rusty-kodi | /kodi-jsonrpc-client/src/main.rs | UTF-8 | 3,001 | 2.546875 | 3 | [] | no_license | use clap::Clap;
use kodi_jsonrpc_client::methods::*;
use kodi_jsonrpc_client::KodiClient;
use reqwest::header::{HeaderMap, HeaderValue, CONNECTION};
use reqwest::Url;
use tracing::{event, Level};
#[derive(Clap)]
#[clap(version = env!("CARGO_PKG_VERSION"), author = env!("CARGO_PKG_AUTHORS"))]
struct Opts {
/// Sets... | true |
09207857123995bf7c946cec9288dcaa6680d03f | Rust | rcore-os-infohub/ossoc2020-luojia65-rcore-lab | /src/kernel/syscall.rs | UTF-8 | 1,979 | 2.703125 | 3 | [] | no_license | use crate::PROCESSOR;
use riscv_sbi_rt::TrapFrame as Context;
const MODULE_PROCESS: usize = 0x23336666;
const MODULE_FS: usize = 0xF0114514;
pub enum SyscallResult {
/// 继续执行,带返回值
Proceed(isize),
/// 返回两个值
ProceedTwo(isize, isize),
/// 记录返回值,但暂存当前线程
Park(isize),
/// 返回两个值
ParkTwo(isize... | true |
b4447a9a8a8fc5ee82d31774b0fcef0e9541ea69 | Rust | pourplusquoi/learn-rust | /leetcode/321.rs | UTF-8 | 1,970 | 3.421875 | 3 | [] | no_license | use std::cmp::min;
// dp[i][j] -> max num using i elements with length j.
// dp[i][j] = max(dp[i - 1][j - 1] `append` nums[i], dp[i - 1][j]),
impl Solution {
pub fn max_number(nums1: Vec<i32>, nums2: Vec<i32>, k_: i32) -> Vec<i32> {
let k = k_ as usize;
let (m, n) = (nums1.len(), nums2.len());
let dp1 =... | true |
13dbff3ae652dc12b8b5cebbcce10600bb6c3fde | Rust | konamilk/atcoder-abc170 | /src/bin/b.rs | UTF-8 | 753 | 2.65625 | 3 | [] | no_license | use proconio::input;
#[allow(unused_imports)]
use proconio::source::auto::AutoSource;
#[allow(unused_imports)]
use proconio::marker::{Chars, Bytes};
#[allow(unused_imports)]
use num::integer::{sqrt, gcd, lcm};
#[allow(unused_imports)]
use std::cmp::{max, min, Reverse};
fn main() {
// let source = AutoSource::from(... | true |
5070ab4fbf65411dbd184fd58a047e88714fe68b | Rust | simnalamburt/fate | /client/src/ui.rs | UTF-8 | 2,631 | 2.765625 | 3 | [] | no_license | use glium::backend::Facade;
use glium::index;
use glium::{DrawError, Program, Surface, VertexBuffer};
use xmath::Matrix;
#[derive(Clone, Copy)]
struct Vertex {
position: [f32; 2],
}
implement_vertex!(Vertex, position);
pub struct UI {
pub cursor: (f32, f32),
pub width: u32,
pub height: u32,
vb: V... | true |
475dce1d7e66af50539599c2447f59b16d66d03a | Rust | aapis/evertils-log-helper | /src/logm.rs | UTF-8 | 837 | 2.625 | 3 | [] | no_license | // log monitoring items
extern crate chrono;
mod helper;
mod log {
use std::env;
use std::process::Command;
use helper;
pub fn exec() {
let args: Vec<String> = env::args().collect();
let message = &args[1];
let output = Command::new("sh")
.arg("-c")
... | true |
9ca2e483a58683494b6d4d07ee39da50923d576e | Rust | oknozor/oknozor.github.io | /common.rs | UTF-8 | 381 | 2.765625 | 3 | [] | no_license | extern crate serde;
use serde::{Deserialize, Serialize};
/// User without its password
#[derive(Serialize, Deserialize, Debug)]
pub struct UserDto {
pub id: i32,
pub nickname: String,
pub email: String,
}
/// Add a new user
#[derive(Serialize, Deserialize, Debug)]
pub struct NewUserDto {
pub nickname... | true |
5f97abf56b007e1880d53738f77f190360fd582e | Rust | MamoruDS/silqfmt | /src/code.rs | UTF-8 | 4,489 | 3.109375 | 3 | [
"MIT"
] | permissive | use std::cmp::Ordering;
pub struct Code {
raw: String,
code: String,
lines: Vec<String>,
depths: Vec<usize>,
tab_size: u8,
hardtab: bool,
_depth: usize,
}
impl Code {
pub fn new(code: String, tab_size: u8, hardtab: bool) -> Code {
Code {
raw: code,
code:... | true |
8f3236069a5829ed68c11660c7e54acb3823d453 | Rust | tempbottle/fht2p | /src/index/model.rs | UTF-8 | 5,549 | 2.953125 | 3 | [
"MIT"
] | permissive | use askama::Template;
use chrono::{DateTime, Local, TimeZone};
use hyper::server::Request;
use hyper_fs::Config;
use tools::url_for_parent;
use views::IndexTemplate;
use std::cmp::Ordering;
use std::fmt;
use std::fs::{self, DirEntry, FileType};
use std::io;
use std::path::{Path, PathBuf};
use std::time;
pub fn rende... | true |
2e1aa5f126dcd031b4a6d9160ff25d5fdf7286f8 | Rust | ibaryshnikov/webgl-engine | /src/buffer_storage.rs | UTF-8 | 1,938 | 2.9375 | 3 | [] | no_license | use std::fmt::Display;
use js_sys::{Error, Float32Array, Uint16Array, WebAssembly};
use wasm_bindgen::{JsCast, JsValue};
use web_sys::{WebGlBuffer, WebGlRenderingContext};
use crate::rendering_context::{get_buffer_type, BufferKind, RenderingContext};
pub struct BufferStorage<T: Display + Sized> {
kind: BufferKin... | true |
8db0d0c61dad3c1074b42352d1eed0403707d73d | Rust | tanzaku/codevs-reborn | /src/lambda_ai.rs | UTF-8 | 3,284 | 2.546875 | 3 | [] | no_license |
// Wの値が紛らわしい
const W: i32 = 10;
const H: i32 = 16;
use std::str::FromStr;
use std::io::Read;
use std::io::StdinLock;
use super::action;
use super::board;
use super::player;
use super::rensa_plan;
const MAX_TURN: usize = 500;
pub struct LambdaAi<'a> {
cur_turn: usize,
stdin_lock: StdinLock<'a>,
packs: ... | true |
2d23d832c28c8ba7670bf17460c2340db25687f7 | Rust | remunds/pasture | /pasture-io/src/ascii/ascii_writer.rs | UTF-8 | 3,729 | 3.1875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use std::{fs::File, io::BufWriter, path::Path};
use anyhow::Result;
use pasture_core::{containers::PointBuffer, layout::PointLayout};
use crate::base::PointWriter;
use super::{AsciiFormat, PointWriterFormatting, RawAsciiWriter};
/// `PointWriterFormatting` implementation for Ascii files
pub struct AsciiWriter {
... | true |
d2e2f20d62f200dd678174d741a68e64ef76dfc4 | Rust | kwryoh/ocp-rust-ex | /src/main.rs | UTF-8 | 2,294 | 2.8125 | 3 | [
"MIT"
] | permissive | use anyhow::Result;
use tracing::{info, Level};
use tracing_subscriber::FmtSubscriber;
use serde_derive::Deserialize;
use hyper::{Body, Request, Response, Server};
use hyper::service::{make_service_fn, service_fn};
use futures_util::future::join;
use std::convert::Infallible;
#[derive(Deserialize, Debug)]
struct Co... | true |
66218177cf33e7b348cef8b56b213c3530da5ecf | Rust | jasonblog/note | /Rust/code/learn_rust/learn_unsafe1/src/main.rs | UTF-8 | 750 | 3.453125 | 3 | [] | no_license | //4、解引用裸指针
//不可变和可变的,分别写作*const T, *mut T
//
//(1)允许忽略借用规则,可以同时拥有不可变和可变的指针,或者是多个指向相同位置的可变指针
//(2)不保证指向的内存是有效的
//(3)允许为空
//(4)不能实现任何自动清理的功能
//
fn main() {
let mut num = 5;
//创建不可变和可变的裸指针可以在安全的代码中,只是不能在不安全代码块之外解引用裸指针
let r1 = &num as *const i32;
let r2 = &mut num as *mut i32;
unsafe {
println... | true |
b828b1531d4b60658f048462bd8fbe0b8c93ce76 | Rust | davidssmith/classic | /src/bin/missionary.rs | UTF-8 | 5,836 | 3.265625 | 3 | [] | no_license | //! Solution to the Missionaries and Cannibals Problem
use std::cmp::Ordering;
use std::collections::{HashSet, VecDeque};
use std::fmt;
use std::rc::Rc;
const MAX_NUM: i32 = 3;
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
struct MCState {
wm: i32,
wc: i32,
em: i32,
ec: i32,
boat: bool,
}
#[... | true |
84c03d5813fb6455322d4b5533454d47cd82011a | Rust | nicholaspun/learn-rust | /5-3-method-syntax/src/main.rs | UTF-8 | 2,768 | 4.1875 | 4 | [] | no_license | fn main() {
{ // We'll begin with what we ended with in 5.2
#[derive(Debug)]
struct Rectangle {
width: u32,
height: u32
}
fn area(rectangle: &Rectangle) -> u32 {
rectangle.width * rectangle.height
}
let rect = Rectangle { width: 3... | true |
ce9f1a0872f90de1ea38e5e2ca0002ae5430fd97 | Rust | AlexNav73/rusty_dam | /libcore/src/fs.rs | UTF-8 | 1,045 | 2.828125 | 3 | [] | no_license |
use std::fs;
use std::path::{Path, PathBuf};
use Entity;
use models::file::File as RFile;
pub(crate) struct FileService {
work_dir: PathBuf
}
impl FileService {
pub(crate) fn new<S: AsRef<Path>>(path: S) -> Self {
if path.as_ref().is_dir() {
FileService { work_dir: path.as_... | true |
55b2b722eff4c486790bd306521a9e50004db160 | Rust | rick68/rust-trace | /libcore/iter/order/ne.rs | UTF-8 | 1,983 | 3.34375 | 3 | [
"MIT"
] | permissive | #![feature(core)]
extern crate core;
#[cfg(test)]
mod tests {
use core::iter::Iterator;
use core::iter::order::ne;
use core::cmp::PartialEq;
struct A<T: PartialEq> {
begin: T,
end: T
}
macro_rules! Iterator_impl {
($T:ty) => {
impl Iterator for A<$T> {
type Item = $T;
fn next(&m... | true |
31d53353373314e456e87c2b03bd5b8aa52922a1 | Rust | pkafma-aon/LeetCode-Rust | /src/single_number.rs | UTF-8 | 361 | 3.34375 | 3 | [
"WTFPL"
] | permissive | impl Solution {
pub fn single_number(nums: Vec<i32>) -> i32 {
nums.iter().fold(0, |ret, x| ret ^ x)
}
}
pub struct Solution;
#[cfg(test)]
mod test {
use super::Solution;
#[test]
fn test() {
assert_eq!(Solution::single_number(vec![2, 2, 1]), 1);
assert_eq!(Solution::single_... | true |
31de85a781aa5e0cd403f489df928cd615211f6d | Rust | rmundy/rg3d | /src/scene2d/camera.rs | UTF-8 | 1,522 | 2.921875 | 3 | [
"MIT"
] | permissive | use crate::core::algebra::Vector2;
use crate::{
core::{algebra::Matrix4, math::Rect, visitor::prelude::*},
scene2d::base::Base,
};
use std::ops::{Deref, DerefMut};
#[derive(Visit)]
pub struct Camera {
base: Base,
viewport: Rect<f32>,
view_matrix: Matrix4<f32>,
projection_matrix: Matrix4<f32>,
... | true |
4aa8efc85737d03c379e79491ff9e8a725d7809c | Rust | frainho/chip8 | /sdl2/src/audio.rs | UTF-8 | 1,454 | 2.890625 | 3 | [] | no_license | use std::error::Error;
use chip8_core::{Audio, Chip8Error};
use sdl2::{
audio::{AudioCallback, AudioDevice, AudioSpecDesired},
Sdl,
};
pub struct SdlAudio {
audio_device: AudioDevice<SquareWave>,
}
impl SdlAudio {
pub fn new(sdl_context: &Sdl) -> Result<SdlAudio, Box<dyn Error>> {
let audio_s... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.